Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(664)

Unified Diff: src/interpreter/interpreter.cc

Issue 1882073002: [Interpreter] Make dispatch table point to code entry instead of code objects. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix visiting dispatch table. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/interpreter.h ('k') | src/interpreter/interpreter-assembler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/interpreter.cc
diff --git a/src/interpreter/interpreter.cc b/src/interpreter/interpreter.cc
index 899ecef417f5e2bc09c6b481b26dcd2fc915fb23..e88faea49807152c02e666875340c7487c0dc7b2 100644
--- a/src/interpreter/interpreter.cc
+++ b/src/interpreter/interpreter.cc
@@ -54,7 +54,7 @@ void Interpreter::Initialize() {
Do##Name(&assembler); \
Handle<Code> code = assembler.GenerateCode(); \
size_t index = GetDispatchTableIndex(Bytecode::k##Name, operand_scale); \
- dispatch_table_[index] = *code; \
+ dispatch_table_[index] = code->entry(); \
TraceCodegen(code); \
LOG_CODE_EVENT( \
isolate_, \
@@ -82,7 +82,8 @@ Code* Interpreter::GetBytecodeHandler(Bytecode bytecode,
DCHECK(IsDispatchTableInitialized());
DCHECK(Bytecodes::BytecodeHasHandler(bytecode, operand_scale));
size_t index = GetDispatchTableIndex(bytecode, operand_scale);
- return dispatch_table_[index];
+ Address code_entry = dispatch_table_[index];
+ return Code::GetCodeFromTargetAddress(code_entry);
}
// static
@@ -99,9 +100,17 @@ size_t Interpreter::GetDispatchTableIndex(Bytecode bytecode,
}
void Interpreter::IterateDispatchTable(ObjectVisitor* v) {
- v->VisitPointers(
- reinterpret_cast<Object**>(&dispatch_table_[0]),
- reinterpret_cast<Object**>(&dispatch_table_[0] + kDispatchTableSize));
+ for (int i = 0; i < kDispatchTableSize; i++) {
+ Address code_entry = dispatch_table_[i];
+ Object* code = code_entry == nullptr
+ ? nullptr
+ : Code::GetCodeFromTargetAddress(code_entry);
+ Object* old_code = code;
+ v->VisitPointer(&code);
+ if (code != old_code) {
+ dispatch_table_[i] = reinterpret_cast<Code*>(code)->entry();
+ }
+ }
}
// static
@@ -179,9 +188,10 @@ void Interpreter::TraceCodegen(Handle<Code> code) {
const char* Interpreter::LookupNameOfBytecodeHandler(Code* code) {
#ifdef ENABLE_DISASSEMBLER
-#define RETURN_NAME(Name, ...) \
- if (dispatch_table_[Bytecodes::ToByte(Bytecode::k##Name)] == code) { \
- return #Name; \
+#define RETURN_NAME(Name, ...) \
+ if (dispatch_table_[Bytecodes::ToByte(Bytecode::k##Name)] == \
+ code->entry()) { \
+ return #Name; \
}
BYTECODE_LIST(RETURN_NAME)
#undef RETURN_NAME
« no previous file with comments | « src/interpreter/interpreter.h ('k') | src/interpreter/interpreter-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698