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

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

Issue 1361113002: [Interpreter] Add support for loading globals in the interpreter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review comments and fix ASAN Created 5 years, 3 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/bytecode-generator.h ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index e40a5b3513eeeb97b9e8c7cda8299136cd427cb5..55fd7c9945a55af00637f40d07e81620cf9c0631 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -251,7 +251,11 @@ void BytecodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
void BytecodeGenerator::VisitVariableProxy(VariableProxy* proxy) {
- Variable* variable = proxy->var();
+ VisitVariableLoad(proxy->var());
+}
+
+
+void BytecodeGenerator::VisitVariableLoad(Variable* variable) {
switch (variable->location()) {
case VariableLocation::LOCAL: {
Register source(variable->index());
@@ -265,7 +269,15 @@ void BytecodeGenerator::VisitVariableProxy(VariableProxy* proxy) {
builder().LoadAccumulatorWithRegister(source);
break;
}
- case VariableLocation::GLOBAL:
+ case VariableLocation::GLOBAL: {
+ // Global var, const, or let variable.
+ // TODO(rmcilroy): If context chain depth is short enough, do this using
+ // a generic version of LoadGlobalViaContextStub rather than calling the
+ // runtime.
+ DCHECK(variable->IsStaticGlobalObjectProperty());
+ builder().LoadGlobal(variable->index());
+ break;
+ }
case VariableLocation::UNALLOCATED:
case VariableLocation::CONTEXT:
case VariableLocation::LOOKUP:
@@ -403,7 +415,15 @@ void BytecodeGenerator::VisitCall(Call* expr) {
builder().StoreAccumulatorInRegister(callee);
break;
}
- case Call::GLOBAL_CALL:
+ case Call::GLOBAL_CALL: {
+ // Receiver is undefined for global calls.
+ builder().LoadUndefined().StoreAccumulatorInRegister(receiver);
+ // Load callee as a global variable.
+ VariableProxy* proxy = callee_expr->AsVariableProxy();
+ VisitVariableLoad(proxy->var());
+ builder().StoreAccumulatorInRegister(callee);
+ break;
+ }
case Call::LOOKUP_SLOT_CALL:
case Call::SUPER_CALL:
case Call::POSSIBLY_EVAL_CALL:
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698