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

Side by Side 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 unified diff | Download patch
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 "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/interpreter/control-flow-builders.h" 9 #include "src/interpreter/control-flow-builders.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 Register destination(builder()->Parameter(variable->index() + 1)); 556 Register destination(builder()->Parameter(variable->index() + 1));
557 builder()->LoadTheHole().StoreAccumulatorInRegister(destination); 557 builder()->LoadTheHole().StoreAccumulatorInRegister(destination);
558 } 558 }
559 break; 559 break;
560 case VariableLocation::CONTEXT: 560 case VariableLocation::CONTEXT:
561 if (hole_init) { 561 if (hole_init) {
562 builder()->LoadTheHole().StoreContextSlot(execution_context()->reg(), 562 builder()->LoadTheHole().StoreContextSlot(execution_context()->reg(),
563 variable->index()); 563 variable->index());
564 } 564 }
565 break; 565 break;
566 case VariableLocation::LOOKUP: 566 case VariableLocation::LOOKUP: {
567 UNIMPLEMENTED(); 567 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.
568 temporary_register_scope.PrepareForConsecutiveAllocations(3);
569 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.
570 Register name = temporary_register_scope.NextConsecutiveRegister();
571 Register init_value = temporary_register_scope.NextConsecutiveRegister();
572 Register attributes = temporary_register_scope.NextConsecutiveRegister();
573 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
574 if (hole_init) {
575 builder()->LoadTheHole().StoreAccumulatorInRegister(init_value);
rmcilroy 2016/01/14 11:21:12 ditto
576 } else {
577 builder()
578 ->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.
579 .StoreAccumulatorInRegister(init_value);
580 }
581 builder()
582 ->LoadLiteral(Smi::FromInt(variable->DeclarationPropertyAttributes()))
583 .StoreAccumulatorInRegister(attributes);
584 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.
568 break; 585 break;
586 }
569 } 587 }
570 } 588 }
571 589
572 590
573 void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { 591 void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) {
574 Variable* variable = decl->proxy()->var(); 592 Variable* variable = decl->proxy()->var();
575 switch (variable->location()) { 593 switch (variable->location()) {
576 case VariableLocation::GLOBAL: 594 case VariableLocation::GLOBAL:
577 case VariableLocation::UNALLOCATED: { 595 case VariableLocation::UNALLOCATED: {
578 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( 596 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo(
(...skipping 10 matching lines...) Expand all
589 VisitVariableAssignment(variable, FeedbackVectorSlot::Invalid()); 607 VisitVariableAssignment(variable, FeedbackVectorSlot::Invalid());
590 break; 608 break;
591 } 609 }
592 case VariableLocation::CONTEXT: { 610 case VariableLocation::CONTEXT: {
593 DCHECK_EQ(0, execution_context()->ContextChainDepth(variable->scope())); 611 DCHECK_EQ(0, execution_context()->ContextChainDepth(variable->scope()));
594 VisitForAccumulatorValue(decl->fun()); 612 VisitForAccumulatorValue(decl->fun());
595 builder()->StoreContextSlot(execution_context()->reg(), 613 builder()->StoreContextSlot(execution_context()->reg(),
596 variable->index()); 614 variable->index());
597 break; 615 break;
598 } 616 }
599 case VariableLocation::LOOKUP: 617 case VariableLocation::LOOKUP: {
600 UNIMPLEMENTED(); 618 TemporaryRegisterScope temporary_register_scope(builder());
619 temporary_register_scope.PrepareForConsecutiveAllocations(3);
620 Register name = temporary_register_scope.NextConsecutiveRegister();
621 Register literal = temporary_register_scope.NextConsecutiveRegister();
622 Register attributes = temporary_register_scope.NextConsecutiveRegister();
623 builder()->LoadLiteral(variable->name()).StoreAccumulatorInRegister(name);
rmcilroy 2016/01/14 11:21:12 newline
mythria 2016/01/15 11:27:04 Done.
624 VisitForAccumulatorValue(decl->fun());
625 builder()->StoreAccumulatorInRegister(literal);
626 builder()
627 ->LoadLiteral(Smi::FromInt(variable->DeclarationPropertyAttributes()))
628 .StoreAccumulatorInRegister(attributes);
629 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.
630 }
601 } 631 }
602 } 632 }
603 633
604 634
605 void BytecodeGenerator::VisitImportDeclaration(ImportDeclaration* decl) { 635 void BytecodeGenerator::VisitImportDeclaration(ImportDeclaration* decl) {
606 UNIMPLEMENTED(); 636 UNIMPLEMENTED();
607 } 637 }
608 638
609 639
610 void BytecodeGenerator::VisitExportDeclaration(ExportDeclaration* decl) { 640 void BytecodeGenerator::VisitExportDeclaration(ExportDeclaration* decl) {
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 builder() 1432 builder()
1403 ->LoadContextSlot(context_reg, Context::PREVIOUS_INDEX) 1433 ->LoadContextSlot(context_reg, Context::PREVIOUS_INDEX)
1404 .StoreAccumulatorInRegister(context_reg); 1434 .StoreAccumulatorInRegister(context_reg);
1405 } 1435 }
1406 builder()->LoadAccumulatorWithRegister(value_temp); 1436 builder()->LoadAccumulatorWithRegister(value_temp);
1407 } 1437 }
1408 builder()->StoreContextSlot(context_reg, variable->index()); 1438 builder()->StoreContextSlot(context_reg, variable->index());
1409 break; 1439 break;
1410 } 1440 }
1411 case VariableLocation::LOOKUP: { 1441 case VariableLocation::LOOKUP: {
1442 // TODO(mythria): Use Runtime::kInitializeLegacyConstLookupSlot for
1443 // initializations of const declarations.
mythria 2016/01/13 17:27:21 This is not related to this cl. I should have adde
1412 builder()->StoreLookupSlot(variable->name(), language_mode()); 1444 builder()->StoreLookupSlot(variable->name(), language_mode());
1413 break; 1445 break;
1414 } 1446 }
1415 } 1447 }
1416 } 1448 }
1417 1449
1418 1450
1419 void BytecodeGenerator::VisitAssignment(Assignment* expr) { 1451 void BytecodeGenerator::VisitAssignment(Assignment* expr) {
1420 DCHECK(expr->target()->IsValidReferenceExpression()); 1452 DCHECK(expr->target()->IsValidReferenceExpression());
1421 Register object, key; 1453 Register object, key;
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
2281 } 2313 }
2282 2314
2283 2315
2284 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 2316 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
2285 return info()->feedback_vector()->GetIndex(slot); 2317 return info()->feedback_vector()->GetIndex(slot);
2286 } 2318 }
2287 2319
2288 } // namespace interpreter 2320 } // namespace interpreter
2289 } // namespace internal 2321 } // namespace internal
2290 } // namespace v8 2322 } // namespace v8
OLDNEW
« 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