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

Unified Diff: src/interpreter/bytecode-generator.cc

Issue 1583783003: [Interpreter] Adds support for variable/function declarations in lookup slots. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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
Index: src/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index 73eee32fcb5aa7b66458639ab91fc363721c0b29..2706741206016526ca7d4acc06d3c38ed6f7df44 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -563,9 +563,27 @@ void BytecodeGenerator::VisitVariableDeclaration(VariableDeclaration* decl) {
variable->index());
}
break;
- case VariableLocation::LOOKUP:
- UNIMPLEMENTED();
+ case VariableLocation::LOOKUP: {
+ TemporaryRegisterScope temporary_register_scope(builder());
rmcilroy 2016/01/14 11:21:12 Please don't use TemporaryRegisterScope (it is goi
mythria 2016/01/15 11:27:04 Done.
+ temporary_register_scope.PrepareForConsecutiveAllocations(3);
+ DCHECK(IsDeclaredVariableMode(mode));
rmcilroy 2016/01/14 11:21:12 nit - move to the top of the case
mythria 2016/01/15 11:27:04 Done.
+ Register name = temporary_register_scope.NextConsecutiveRegister();
+ Register init_value = temporary_register_scope.NextConsecutiveRegister();
+ Register attributes = temporary_register_scope.NextConsecutiveRegister();
+ builder()->LoadLiteral(variable->name()).StoreAccumulatorInRegister(name);
rmcilroy 2016/01/14 11:21:12 nit - newline abovem, and newline between LoadLite
mythria 2016/01/15 11:27:04 I am not sure, I understood this correctly. cl for
+ if (hole_init) {
+ builder()->LoadTheHole().StoreAccumulatorInRegister(init_value);
rmcilroy 2016/01/14 11:21:12 ditto
+ } else {
+ builder()
+ ->LoadLiteral(Smi::FromInt(0))
rmcilroy 2016/01/14 11:21:12 Add comment that this indicates no initial value a
mythria 2016/01/15 11:27:04 Done.
+ .StoreAccumulatorInRegister(init_value);
+ }
+ builder()
+ ->LoadLiteral(Smi::FromInt(variable->DeclarationPropertyAttributes()))
+ .StoreAccumulatorInRegister(attributes);
+ builder()->CallRuntime(Runtime::kDeclareLookupSlot, name, 3);
rmcilroy 2016/01/14 11:21:12 nit - no need for builder() here
mythria 2016/01/15 11:27:04 Done.
break;
+ }
}
}
@@ -596,8 +614,20 @@ void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) {
variable->index());
break;
}
- case VariableLocation::LOOKUP:
- UNIMPLEMENTED();
+ case VariableLocation::LOOKUP: {
+ TemporaryRegisterScope temporary_register_scope(builder());
+ temporary_register_scope.PrepareForConsecutiveAllocations(3);
+ Register name = temporary_register_scope.NextConsecutiveRegister();
+ Register literal = temporary_register_scope.NextConsecutiveRegister();
+ Register attributes = temporary_register_scope.NextConsecutiveRegister();
+ builder()->LoadLiteral(variable->name()).StoreAccumulatorInRegister(name);
rmcilroy 2016/01/14 11:21:12 newline
mythria 2016/01/15 11:27:04 Done.
+ VisitForAccumulatorValue(decl->fun());
+ builder()->StoreAccumulatorInRegister(literal);
+ builder()
+ ->LoadLiteral(Smi::FromInt(variable->DeclarationPropertyAttributes()))
+ .StoreAccumulatorInRegister(attributes);
+ builder()->CallRuntime(Runtime::kDeclareLookupSlot, name, 3);
rmcilroy 2016/01/14 11:21:12 only one builder() for these 5 lines
mythria 2016/01/15 11:27:04 Done.
+ }
}
}
@@ -1409,6 +1439,8 @@ void BytecodeGenerator::VisitVariableAssignment(Variable* variable,
break;
}
case VariableLocation::LOOKUP: {
+ // TODO(mythria): Use Runtime::kInitializeLegacyConstLookupSlot for
+ // initializations of const declarations.
mythria 2016/01/13 17:27:21 This is not related to this cl. I should have adde
builder()->StoreLookupSlot(variable->name(), language_mode());
break;
}
« no previous file with comments | « no previous file | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | test/cctest/interpreter/test-bytecode-generator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698