summaryrefslogtreecommitdiff
path: root/deps/v8/src/interpreter/bytecode-array-writer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/interpreter/bytecode-array-writer.cc')
-rw-r--r--deps/v8/src/interpreter/bytecode-array-writer.cc47
1 files changed, 36 insertions, 11 deletions
diff --git a/deps/v8/src/interpreter/bytecode-array-writer.cc b/deps/v8/src/interpreter/bytecode-array-writer.cc
index 3ecc5e1a89..3a459b4833 100644
--- a/deps/v8/src/interpreter/bytecode-array-writer.cc
+++ b/deps/v8/src/interpreter/bytecode-array-writer.cc
@@ -12,7 +12,6 @@
#include "src/interpreter/bytecode-source-info.h"
#include "src/interpreter/constant-array-builder.h"
#include "src/interpreter/handler-table-builder.h"
-#include "src/logging/log.h"
#include "src/objects/objects-inl.h"
namespace v8 {
@@ -50,19 +49,43 @@ Handle<BytecodeArray> BytecodeArrayWriter::ToBytecodeArray(
bytecode_size, &bytecodes()->front(), frame_size, parameter_count,
constant_pool);
bytecode_array->set_handler_table(*handler_table);
- if (!source_position_table_builder_.Lazy()) {
- Handle<ByteArray> source_position_table =
- source_position_table_builder_.Omit()
- ? ReadOnlyRoots(isolate).empty_byte_array_handle()
- : source_position_table_builder()->ToSourcePositionTable(isolate);
- bytecode_array->set_source_position_table(*source_position_table);
- LOG_CODE_EVENT(isolate, CodeLinePosInfoRecordEvent(
- bytecode_array->GetFirstBytecodeAddress(),
- *source_position_table));
- }
return bytecode_array;
}
+Handle<ByteArray> BytecodeArrayWriter::ToSourcePositionTable(Isolate* isolate) {
+ DCHECK(!source_position_table_builder_.Lazy());
+ Handle<ByteArray> source_position_table =
+ source_position_table_builder_.Omit()
+ ? ReadOnlyRoots(isolate).empty_byte_array_handle()
+ : source_position_table_builder_.ToSourcePositionTable(isolate);
+ return source_position_table;
+}
+
+#ifdef DEBUG
+int BytecodeArrayWriter::CheckBytecodeMatches(Handle<BytecodeArray> bytecode) {
+ int mismatches = false;
+ int bytecode_size = static_cast<int>(bytecodes()->size());
+ const byte* bytecode_ptr = &bytecodes()->front();
+ if (bytecode_size != bytecode->length()) mismatches = true;
+
+ // If there's a mismatch only in the length of the bytecode (very unlikely)
+ // then the first mismatch will be the first extra bytecode.
+ int first_mismatch = std::min(bytecode_size, bytecode->length());
+ for (int i = 0; i < first_mismatch; ++i) {
+ if (bytecode_ptr[i] != bytecode->get(i)) {
+ mismatches = true;
+ first_mismatch = i;
+ break;
+ }
+ }
+
+ if (mismatches) {
+ return first_mismatch;
+ }
+ return -1;
+}
+#endif
+
void BytecodeArrayWriter::Write(BytecodeNode* node) {
DCHECK(!Bytecodes::IsJump(node->bytecode()));
@@ -286,6 +309,8 @@ Bytecode GetJumpWithConstantOperand(Bytecode jump_bytecode) {
return Bytecode::kJumpIfUndefinedConstant;
case Bytecode::kJumpIfNotUndefined:
return Bytecode::kJumpIfNotUndefinedConstant;
+ case Bytecode::kJumpIfUndefinedOrNull:
+ return Bytecode::kJumpIfUndefinedOrNullConstant;
case Bytecode::kJumpIfJSReceiver:
return Bytecode::kJumpIfJSReceiverConstant;
default: