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

Side by Side 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, 2 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 unified diff | Download patch
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/interpreter/bytecode-generator.h" 5 #include "src/interpreter/bytecode-generator.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 UNIMPLEMENTED(); 244 UNIMPLEMENTED();
245 } 245 }
246 246
247 247
248 void BytecodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 248 void BytecodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
249 UNIMPLEMENTED(); 249 UNIMPLEMENTED();
250 } 250 }
251 251
252 252
253 void BytecodeGenerator::VisitVariableProxy(VariableProxy* proxy) { 253 void BytecodeGenerator::VisitVariableProxy(VariableProxy* proxy) {
254 Variable* variable = proxy->var(); 254 VisitVariableLoad(proxy->var());
255 }
256
257
258 void BytecodeGenerator::VisitVariableLoad(Variable* variable) {
255 switch (variable->location()) { 259 switch (variable->location()) {
256 case VariableLocation::LOCAL: { 260 case VariableLocation::LOCAL: {
257 Register source(variable->index()); 261 Register source(variable->index());
258 builder().LoadAccumulatorWithRegister(source); 262 builder().LoadAccumulatorWithRegister(source);
259 break; 263 break;
260 } 264 }
261 case VariableLocation::PARAMETER: { 265 case VariableLocation::PARAMETER: {
262 // The parameter indices are shifted by 1 (receiver is variable 266 // The parameter indices are shifted by 1 (receiver is variable
263 // index -1 but is parameter index 0 in BytecodeArrayBuilder). 267 // index -1 but is parameter index 0 in BytecodeArrayBuilder).
264 Register source(builder().Parameter(variable->index() + 1)); 268 Register source(builder().Parameter(variable->index() + 1));
265 builder().LoadAccumulatorWithRegister(source); 269 builder().LoadAccumulatorWithRegister(source);
266 break; 270 break;
267 } 271 }
268 case VariableLocation::GLOBAL: 272 case VariableLocation::GLOBAL: {
273 // Global var, const, or let variable.
274 // TODO(rmcilroy): If context chain depth is short enough, do this using
275 // a generic version of LoadGlobalViaContextStub rather than calling the
276 // runtime.
277 DCHECK(variable->IsStaticGlobalObjectProperty());
278 builder().LoadGlobal(variable->index());
279 break;
280 }
269 case VariableLocation::UNALLOCATED: 281 case VariableLocation::UNALLOCATED:
270 case VariableLocation::CONTEXT: 282 case VariableLocation::CONTEXT:
271 case VariableLocation::LOOKUP: 283 case VariableLocation::LOOKUP:
272 UNIMPLEMENTED(); 284 UNIMPLEMENTED();
273 } 285 }
274 } 286 }
275 287
276 288
277 void BytecodeGenerator::VisitAssignment(Assignment* expr) { 289 void BytecodeGenerator::VisitAssignment(Assignment* expr) {
278 DCHECK(expr->target()->IsValidReferenceExpression()); 290 DCHECK(expr->target()->IsValidReferenceExpression());
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 if (property->IsSuperAccess()) { 408 if (property->IsSuperAccess()) {
397 UNIMPLEMENTED(); 409 UNIMPLEMENTED();
398 } 410 }
399 Visit(property->obj()); 411 Visit(property->obj());
400 builder().StoreAccumulatorInRegister(receiver); 412 builder().StoreAccumulatorInRegister(receiver);
401 // Perform a property load of the callee. 413 // Perform a property load of the callee.
402 VisitPropertyLoad(receiver, property); 414 VisitPropertyLoad(receiver, property);
403 builder().StoreAccumulatorInRegister(callee); 415 builder().StoreAccumulatorInRegister(callee);
404 break; 416 break;
405 } 417 }
406 case Call::GLOBAL_CALL: 418 case Call::GLOBAL_CALL: {
419 // Receiver is undefined for global calls.
420 builder().LoadUndefined().StoreAccumulatorInRegister(receiver);
421 // Load callee as a global variable.
422 VariableProxy* proxy = callee_expr->AsVariableProxy();
423 VisitVariableLoad(proxy->var());
424 builder().StoreAccumulatorInRegister(callee);
425 break;
426 }
407 case Call::LOOKUP_SLOT_CALL: 427 case Call::LOOKUP_SLOT_CALL:
408 case Call::SUPER_CALL: 428 case Call::SUPER_CALL:
409 case Call::POSSIBLY_EVAL_CALL: 429 case Call::POSSIBLY_EVAL_CALL:
410 case Call::OTHER_CALL: 430 case Call::OTHER_CALL:
411 UNIMPLEMENTED(); 431 UNIMPLEMENTED();
412 } 432 }
413 433
414 // Evaluate all arguments to the function call and store in sequential 434 // Evaluate all arguments to the function call and store in sequential
415 // registers. 435 // registers.
416 ZoneList<Expression*>* args = expr->arguments(); 436 ZoneList<Expression*>* args = expr->arguments();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 } 526 }
507 527
508 528
509 int BytecodeGenerator::feedback_index(FeedbackVectorICSlot slot) const { 529 int BytecodeGenerator::feedback_index(FeedbackVectorICSlot slot) const {
510 return info()->feedback_vector()->GetIndex(slot); 530 return info()->feedback_vector()->GetIndex(slot);
511 } 531 }
512 532
513 } // namespace interpreter 533 } // namespace interpreter
514 } // namespace internal 534 } // namespace internal
515 } // namespace v8 535 } // namespace v8
OLDNEW
« 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