OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_PPC | 7 #if V8_TARGET_ARCH_PPC |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 } else { | 356 } else { |
357 PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); | 357 PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); |
358 { | 358 { |
359 Comment cmnt(masm_, "[ Declarations"); | 359 Comment cmnt(masm_, "[ Declarations"); |
360 // For named function expressions, declare the function name as a | 360 // For named function expressions, declare the function name as a |
361 // constant. | 361 // constant. |
362 if (scope()->is_function_scope() && scope()->function() != NULL) { | 362 if (scope()->is_function_scope() && scope()->function() != NULL) { |
363 VariableDeclaration* function = scope()->function(); | 363 VariableDeclaration* function = scope()->function(); |
364 DCHECK(function->proxy()->var()->mode() == CONST || | 364 DCHECK(function->proxy()->var()->mode() == CONST || |
365 function->proxy()->var()->mode() == CONST_LEGACY); | 365 function->proxy()->var()->mode() == CONST_LEGACY); |
366 DCHECK(function->proxy()->var()->location() != Variable::UNALLOCATED); | 366 DCHECK(!function->proxy()->var()->IsUnallocatedOrGlobalSlot()); |
367 VisitVariableDeclaration(function); | 367 VisitVariableDeclaration(function); |
368 } | 368 } |
369 VisitDeclarations(scope()->declarations()); | 369 VisitDeclarations(scope()->declarations()); |
370 } | 370 } |
371 | 371 |
372 { | 372 { |
373 Comment cmnt(masm_, "[ Stack check"); | 373 Comment cmnt(masm_, "[ Stack check"); |
374 PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS); | 374 PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS); |
375 Label ok; | 375 Label ok; |
376 __ LoadRoot(ip, Heap::kStackLimitRootIndex); | 376 __ LoadRoot(ip, Heap::kStackLimitRootIndex); |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 void FullCodeGenerator::VisitVariableDeclaration( | 843 void FullCodeGenerator::VisitVariableDeclaration( |
844 VariableDeclaration* declaration) { | 844 VariableDeclaration* declaration) { |
845 // If it was not possible to allocate the variable at compile time, we | 845 // If it was not possible to allocate the variable at compile time, we |
846 // need to "declare" it at runtime to make sure it actually exists in the | 846 // need to "declare" it at runtime to make sure it actually exists in the |
847 // local context. | 847 // local context. |
848 VariableProxy* proxy = declaration->proxy(); | 848 VariableProxy* proxy = declaration->proxy(); |
849 VariableMode mode = declaration->mode(); | 849 VariableMode mode = declaration->mode(); |
850 Variable* variable = proxy->var(); | 850 Variable* variable = proxy->var(); |
851 bool hole_init = mode == LET || mode == CONST || mode == CONST_LEGACY; | 851 bool hole_init = mode == LET || mode == CONST || mode == CONST_LEGACY; |
852 switch (variable->location()) { | 852 switch (variable->location()) { |
853 case Variable::UNALLOCATED: | 853 case VariableLocation::GLOBAL: |
| 854 case VariableLocation::UNALLOCATED: |
854 globals_->Add(variable->name(), zone()); | 855 globals_->Add(variable->name(), zone()); |
855 globals_->Add(variable->binding_needs_init() | 856 globals_->Add(variable->binding_needs_init() |
856 ? isolate()->factory()->the_hole_value() | 857 ? isolate()->factory()->the_hole_value() |
857 : isolate()->factory()->undefined_value(), | 858 : isolate()->factory()->undefined_value(), |
858 zone()); | 859 zone()); |
859 break; | 860 break; |
860 | 861 |
861 case Variable::PARAMETER: | 862 case VariableLocation::PARAMETER: |
862 case Variable::LOCAL: | 863 case VariableLocation::LOCAL: |
863 if (hole_init) { | 864 if (hole_init) { |
864 Comment cmnt(masm_, "[ VariableDeclaration"); | 865 Comment cmnt(masm_, "[ VariableDeclaration"); |
865 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); | 866 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
866 __ StoreP(ip, StackOperand(variable)); | 867 __ StoreP(ip, StackOperand(variable)); |
867 } | 868 } |
868 break; | 869 break; |
869 | 870 |
870 case Variable::CONTEXT: | 871 case VariableLocation::CONTEXT: |
871 if (hole_init) { | 872 if (hole_init) { |
872 Comment cmnt(masm_, "[ VariableDeclaration"); | 873 Comment cmnt(masm_, "[ VariableDeclaration"); |
873 EmitDebugCheckDeclarationContext(variable); | 874 EmitDebugCheckDeclarationContext(variable); |
874 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); | 875 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
875 __ StoreP(ip, ContextOperand(cp, variable->index()), r0); | 876 __ StoreP(ip, ContextOperand(cp, variable->index()), r0); |
876 // No write barrier since the_hole_value is in old space. | 877 // No write barrier since the_hole_value is in old space. |
877 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 878 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); |
878 } | 879 } |
879 break; | 880 break; |
880 | 881 |
881 case Variable::LOOKUP: { | 882 case VariableLocation::LOOKUP: { |
882 Comment cmnt(masm_, "[ VariableDeclaration"); | 883 Comment cmnt(masm_, "[ VariableDeclaration"); |
883 __ mov(r5, Operand(variable->name())); | 884 __ mov(r5, Operand(variable->name())); |
884 // Declaration nodes are always introduced in one of four modes. | 885 // Declaration nodes are always introduced in one of four modes. |
885 DCHECK(IsDeclaredVariableMode(mode)); | 886 DCHECK(IsDeclaredVariableMode(mode)); |
886 PropertyAttributes attr = | 887 PropertyAttributes attr = |
887 IsImmutableVariableMode(mode) ? READ_ONLY : NONE; | 888 IsImmutableVariableMode(mode) ? READ_ONLY : NONE; |
888 __ LoadSmiLiteral(r4, Smi::FromInt(attr)); | 889 __ LoadSmiLiteral(r4, Smi::FromInt(attr)); |
889 // Push initial value, if any. | 890 // Push initial value, if any. |
890 // Note: For variables we must not push an initial value (such as | 891 // Note: For variables we must not push an initial value (such as |
891 // 'undefined') because we may have a (legal) redeclaration and we | 892 // 'undefined') because we may have a (legal) redeclaration and we |
(...skipping 10 matching lines...) Expand all Loading... |
902 } | 903 } |
903 } | 904 } |
904 } | 905 } |
905 | 906 |
906 | 907 |
907 void FullCodeGenerator::VisitFunctionDeclaration( | 908 void FullCodeGenerator::VisitFunctionDeclaration( |
908 FunctionDeclaration* declaration) { | 909 FunctionDeclaration* declaration) { |
909 VariableProxy* proxy = declaration->proxy(); | 910 VariableProxy* proxy = declaration->proxy(); |
910 Variable* variable = proxy->var(); | 911 Variable* variable = proxy->var(); |
911 switch (variable->location()) { | 912 switch (variable->location()) { |
912 case Variable::UNALLOCATED: { | 913 case VariableLocation::GLOBAL: |
| 914 case VariableLocation::UNALLOCATED: { |
913 globals_->Add(variable->name(), zone()); | 915 globals_->Add(variable->name(), zone()); |
914 Handle<SharedFunctionInfo> function = | 916 Handle<SharedFunctionInfo> function = |
915 Compiler::GetSharedFunctionInfo(declaration->fun(), script(), info_); | 917 Compiler::GetSharedFunctionInfo(declaration->fun(), script(), info_); |
916 // Check for stack-overflow exception. | 918 // Check for stack-overflow exception. |
917 if (function.is_null()) return SetStackOverflow(); | 919 if (function.is_null()) return SetStackOverflow(); |
918 globals_->Add(function, zone()); | 920 globals_->Add(function, zone()); |
919 break; | 921 break; |
920 } | 922 } |
921 | 923 |
922 case Variable::PARAMETER: | 924 case VariableLocation::PARAMETER: |
923 case Variable::LOCAL: { | 925 case VariableLocation::LOCAL: { |
924 Comment cmnt(masm_, "[ FunctionDeclaration"); | 926 Comment cmnt(masm_, "[ FunctionDeclaration"); |
925 VisitForAccumulatorValue(declaration->fun()); | 927 VisitForAccumulatorValue(declaration->fun()); |
926 __ StoreP(result_register(), StackOperand(variable)); | 928 __ StoreP(result_register(), StackOperand(variable)); |
927 break; | 929 break; |
928 } | 930 } |
929 | 931 |
930 case Variable::CONTEXT: { | 932 case VariableLocation::CONTEXT: { |
931 Comment cmnt(masm_, "[ FunctionDeclaration"); | 933 Comment cmnt(masm_, "[ FunctionDeclaration"); |
932 EmitDebugCheckDeclarationContext(variable); | 934 EmitDebugCheckDeclarationContext(variable); |
933 VisitForAccumulatorValue(declaration->fun()); | 935 VisitForAccumulatorValue(declaration->fun()); |
934 __ StoreP(result_register(), ContextOperand(cp, variable->index()), r0); | 936 __ StoreP(result_register(), ContextOperand(cp, variable->index()), r0); |
935 int offset = Context::SlotOffset(variable->index()); | 937 int offset = Context::SlotOffset(variable->index()); |
936 // We know that we have written a function, which is not a smi. | 938 // We know that we have written a function, which is not a smi. |
937 __ RecordWriteContextSlot(cp, offset, result_register(), r5, | 939 __ RecordWriteContextSlot(cp, offset, result_register(), r5, |
938 kLRHasBeenSaved, kDontSaveFPRegs, | 940 kLRHasBeenSaved, kDontSaveFPRegs, |
939 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | 941 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
940 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); | 942 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); |
941 break; | 943 break; |
942 } | 944 } |
943 | 945 |
944 case Variable::LOOKUP: { | 946 case VariableLocation::LOOKUP: { |
945 Comment cmnt(masm_, "[ FunctionDeclaration"); | 947 Comment cmnt(masm_, "[ FunctionDeclaration"); |
946 __ mov(r5, Operand(variable->name())); | 948 __ mov(r5, Operand(variable->name())); |
947 __ LoadSmiLiteral(r4, Smi::FromInt(NONE)); | 949 __ LoadSmiLiteral(r4, Smi::FromInt(NONE)); |
948 __ Push(cp, r5, r4); | 950 __ Push(cp, r5, r4); |
949 // Push initial value for function declaration. | 951 // Push initial value for function declaration. |
950 VisitForStackValue(declaration->fun()); | 952 VisitForStackValue(declaration->fun()); |
951 __ CallRuntime(Runtime::kDeclareLookupSlot, 4); | 953 __ CallRuntime(Runtime::kDeclareLookupSlot, 4); |
952 break; | 954 break; |
953 } | 955 } |
954 } | 956 } |
955 } | 957 } |
956 | 958 |
957 | 959 |
958 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) { | 960 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) { |
959 VariableProxy* proxy = declaration->proxy(); | 961 VariableProxy* proxy = declaration->proxy(); |
960 Variable* variable = proxy->var(); | 962 Variable* variable = proxy->var(); |
961 switch (variable->location()) { | 963 switch (variable->location()) { |
962 case Variable::UNALLOCATED: | 964 case VariableLocation::GLOBAL: |
| 965 case VariableLocation::UNALLOCATED: |
963 // TODO(rossberg) | 966 // TODO(rossberg) |
964 break; | 967 break; |
965 | 968 |
966 case Variable::CONTEXT: { | 969 case VariableLocation::CONTEXT: { |
967 Comment cmnt(masm_, "[ ImportDeclaration"); | 970 Comment cmnt(masm_, "[ ImportDeclaration"); |
968 EmitDebugCheckDeclarationContext(variable); | 971 EmitDebugCheckDeclarationContext(variable); |
969 // TODO(rossberg) | 972 // TODO(rossberg) |
970 break; | 973 break; |
971 } | 974 } |
972 | 975 |
973 case Variable::PARAMETER: | 976 case VariableLocation::PARAMETER: |
974 case Variable::LOCAL: | 977 case VariableLocation::LOCAL: |
975 case Variable::LOOKUP: | 978 case VariableLocation::LOOKUP: |
976 UNREACHABLE(); | 979 UNREACHABLE(); |
977 } | 980 } |
978 } | 981 } |
979 | 982 |
980 | 983 |
981 void FullCodeGenerator::VisitExportDeclaration(ExportDeclaration* declaration) { | 984 void FullCodeGenerator::VisitExportDeclaration(ExportDeclaration* declaration) { |
982 // TODO(rossberg) | 985 // TODO(rossberg) |
983 } | 986 } |
984 | 987 |
985 | 988 |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 | 1463 |
1461 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) { | 1464 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) { |
1462 // Record position before possible IC call. | 1465 // Record position before possible IC call. |
1463 SetSourcePosition(proxy->position()); | 1466 SetSourcePosition(proxy->position()); |
1464 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); | 1467 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); |
1465 Variable* var = proxy->var(); | 1468 Variable* var = proxy->var(); |
1466 | 1469 |
1467 // Three cases: global variables, lookup variables, and all other types of | 1470 // Three cases: global variables, lookup variables, and all other types of |
1468 // variables. | 1471 // variables. |
1469 switch (var->location()) { | 1472 switch (var->location()) { |
1470 case Variable::UNALLOCATED: { | 1473 case VariableLocation::GLOBAL: |
| 1474 case VariableLocation::UNALLOCATED: { |
1471 Comment cmnt(masm_, "[ Global variable"); | 1475 Comment cmnt(masm_, "[ Global variable"); |
1472 __ LoadP(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1476 __ LoadP(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1473 __ mov(LoadDescriptor::NameRegister(), Operand(var->name())); | 1477 __ mov(LoadDescriptor::NameRegister(), Operand(var->name())); |
1474 __ mov(LoadDescriptor::SlotRegister(), | 1478 __ mov(LoadDescriptor::SlotRegister(), |
1475 Operand(SmiFromSlot(proxy->VariableFeedbackSlot()))); | 1479 Operand(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
1476 CallGlobalLoadIC(var->name()); | 1480 CallGlobalLoadIC(var->name()); |
1477 context()->Plug(r3); | 1481 context()->Plug(r3); |
1478 break; | 1482 break; |
1479 } | 1483 } |
1480 | 1484 |
1481 case Variable::PARAMETER: | 1485 case VariableLocation::PARAMETER: |
1482 case Variable::LOCAL: | 1486 case VariableLocation::LOCAL: |
1483 case Variable::CONTEXT: { | 1487 case VariableLocation::CONTEXT: { |
1484 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" | 1488 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" |
1485 : "[ Stack variable"); | 1489 : "[ Stack variable"); |
1486 if (var->binding_needs_init()) { | 1490 if (var->binding_needs_init()) { |
1487 // var->scope() may be NULL when the proxy is located in eval code and | 1491 // var->scope() may be NULL when the proxy is located in eval code and |
1488 // refers to a potential outside binding. Currently those bindings are | 1492 // refers to a potential outside binding. Currently those bindings are |
1489 // always looked up dynamically, i.e. in that case | 1493 // always looked up dynamically, i.e. in that case |
1490 // var->location() == LOOKUP. | 1494 // var->location() == LOOKUP. |
1491 // always holds. | 1495 // always holds. |
1492 DCHECK(var->scope() != NULL); | 1496 DCHECK(var->scope() != NULL); |
1493 | 1497 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 } | 1546 } |
1543 __ bind(&done); | 1547 __ bind(&done); |
1544 context()->Plug(r3); | 1548 context()->Plug(r3); |
1545 break; | 1549 break; |
1546 } | 1550 } |
1547 } | 1551 } |
1548 context()->Plug(var); | 1552 context()->Plug(var); |
1549 break; | 1553 break; |
1550 } | 1554 } |
1551 | 1555 |
1552 case Variable::LOOKUP: { | 1556 case VariableLocation::LOOKUP: { |
1553 Comment cmnt(masm_, "[ Lookup variable"); | 1557 Comment cmnt(masm_, "[ Lookup variable"); |
1554 Label done, slow; | 1558 Label done, slow; |
1555 // Generate code for loading from variables potentially shadowed | 1559 // Generate code for loading from variables potentially shadowed |
1556 // by eval-introduced variables. | 1560 // by eval-introduced variables. |
1557 EmitDynamicLookupFastCase(proxy, NOT_INSIDE_TYPEOF, &slow, &done); | 1561 EmitDynamicLookupFastCase(proxy, NOT_INSIDE_TYPEOF, &slow, &done); |
1558 __ bind(&slow); | 1562 __ bind(&slow); |
1559 __ mov(r4, Operand(var->name())); | 1563 __ mov(r4, Operand(var->name())); |
1560 __ Push(cp, r4); // Context and name. | 1564 __ Push(cp, r4); // Context and name. |
1561 __ CallRuntime(Runtime::kLoadLookupSlot, 2); | 1565 __ CallRuntime(Runtime::kLoadLookupSlot, 2); |
1562 __ bind(&done); | 1566 __ bind(&done); |
(...skipping 4028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5591 return ON_STACK_REPLACEMENT; | 5595 return ON_STACK_REPLACEMENT; |
5592 } | 5596 } |
5593 | 5597 |
5594 DCHECK(interrupt_address == | 5598 DCHECK(interrupt_address == |
5595 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5599 isolate->builtins()->OsrAfterStackCheck()->entry()); |
5596 return OSR_AFTER_STACK_CHECK; | 5600 return OSR_AFTER_STACK_CHECK; |
5597 } | 5601 } |
5598 } // namespace internal | 5602 } // namespace internal |
5599 } // namespace v8 | 5603 } // namespace v8 |
5600 #endif // V8_TARGET_ARCH_PPC | 5604 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |