OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 // Push initial value for function declaration. | 904 // Push initial value for function declaration. |
905 VisitForStackValue(declaration->fun()); | 905 VisitForStackValue(declaration->fun()); |
906 __ CallRuntime(Runtime::kDeclareContextSlot, 4); | 906 __ CallRuntime(Runtime::kDeclareContextSlot, 4); |
907 break; | 907 break; |
908 } | 908 } |
909 } | 909 } |
910 } | 910 } |
911 | 911 |
912 | 912 |
913 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { | 913 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { |
914 VariableProxy* proxy = declaration->proxy(); | 914 Variable* variable = declaration->proxy()->var(); |
915 Variable* variable = proxy->var(); | 915 ASSERT(variable->location() == Variable::CONTEXT); |
916 Handle<JSModule> instance = declaration->module()->interface()->Instance(); | 916 ASSERT(variable->interface()->IsFrozen()); |
917 ASSERT(!instance.is_null()); | |
918 | 917 |
919 switch (variable->location()) { | 918 Comment cmnt(masm_, "[ ModuleDeclaration"); |
920 case Variable::UNALLOCATED: { | 919 EmitDebugCheckDeclarationContext(variable); |
921 Comment cmnt(masm_, "[ ModuleDeclaration"); | |
922 globals_->Add(variable->name(), zone()); | |
923 globals_->Add(instance, zone()); | |
924 Visit(declaration->module()); | |
925 break; | |
926 } | |
927 | 920 |
928 case Variable::CONTEXT: { | 921 // Load instance object. |
929 Comment cmnt(masm_, "[ ModuleDeclaration"); | 922 __ LoadContext(r1, scope_->ContextChainLength(scope_->GlobalScope())); |
930 EmitDebugCheckDeclarationContext(variable); | 923 __ ldr(r1, ContextOperand(r1, variable->interface()->Index())); |
931 __ mov(r1, Operand(instance)); | 924 __ ldr(r1, ContextOperand(r1, Context::EXTENSION_INDEX)); |
932 __ str(r1, ContextOperand(cp, variable->index())); | |
933 Visit(declaration->module()); | |
934 break; | |
935 } | |
936 | 925 |
937 case Variable::PARAMETER: | 926 // Assign it. |
938 case Variable::LOCAL: | 927 __ str(r1, ContextOperand(cp, variable->index())); |
939 case Variable::LOOKUP: | 928 // We know that we have written a module, which is not a smi. |
940 UNREACHABLE(); | 929 __ RecordWriteContextSlot(cp, |
941 } | 930 Context::SlotOffset(variable->index()), |
| 931 r1, |
| 932 r3, |
| 933 kLRHasBeenSaved, |
| 934 kDontSaveFPRegs, |
| 935 EMIT_REMEMBERED_SET, |
| 936 OMIT_SMI_CHECK); |
| 937 PrepareForBailoutForId(declaration->proxy()->id(), NO_REGISTERS); |
| 938 |
| 939 // Traverse into body. |
| 940 Visit(declaration->module()); |
942 } | 941 } |
943 | 942 |
944 | 943 |
945 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) { | 944 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) { |
946 VariableProxy* proxy = declaration->proxy(); | 945 VariableProxy* proxy = declaration->proxy(); |
947 Variable* variable = proxy->var(); | 946 Variable* variable = proxy->var(); |
948 switch (variable->location()) { | 947 switch (variable->location()) { |
949 case Variable::UNALLOCATED: | 948 case Variable::UNALLOCATED: |
950 // TODO(rossberg) | 949 // TODO(rossberg) |
951 break; | 950 break; |
(...skipping 22 matching lines...) Expand all Loading... |
974 // Call the runtime to declare the globals. | 973 // Call the runtime to declare the globals. |
975 // The context is the first argument. | 974 // The context is the first argument. |
976 __ mov(r1, Operand(pairs)); | 975 __ mov(r1, Operand(pairs)); |
977 __ mov(r0, Operand(Smi::FromInt(DeclareGlobalsFlags()))); | 976 __ mov(r0, Operand(Smi::FromInt(DeclareGlobalsFlags()))); |
978 __ Push(cp, r1, r0); | 977 __ Push(cp, r1, r0); |
979 __ CallRuntime(Runtime::kDeclareGlobals, 3); | 978 __ CallRuntime(Runtime::kDeclareGlobals, 3); |
980 // Return value is ignored. | 979 // Return value is ignored. |
981 } | 980 } |
982 | 981 |
983 | 982 |
| 983 void FullCodeGenerator::DeclareModules(Handle<FixedArray> descriptions) { |
| 984 // Call the runtime to declare the modules. |
| 985 __ Push(descriptions); |
| 986 __ CallRuntime(Runtime::kDeclareModules, 1); |
| 987 // Return value is ignored. |
| 988 } |
| 989 |
| 990 |
984 void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { | 991 void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { |
985 Comment cmnt(masm_, "[ SwitchStatement"); | 992 Comment cmnt(masm_, "[ SwitchStatement"); |
986 Breakable nested_statement(this, stmt); | 993 Breakable nested_statement(this, stmt); |
987 SetStatementPosition(stmt); | 994 SetStatementPosition(stmt); |
988 | 995 |
989 // Keep the switch value on the stack until a case matches. | 996 // Keep the switch value on the stack until a case matches. |
990 VisitForStackValue(stmt->tag()); | 997 VisitForStackValue(stmt->tag()); |
991 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); | 998 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); |
992 | 999 |
993 ZoneList<CaseClause*>* clauses = stmt->cases(); | 1000 ZoneList<CaseClause*>* clauses = stmt->cases(); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1381 // eval-introduced variables. Eval is used a lot without | 1388 // eval-introduced variables. Eval is used a lot without |
1382 // introducing variables. In those cases, we do not want to | 1389 // introducing variables. In those cases, we do not want to |
1383 // perform a runtime call for all variables in the scope | 1390 // perform a runtime call for all variables in the scope |
1384 // containing the eval. | 1391 // containing the eval. |
1385 if (var->mode() == DYNAMIC_GLOBAL) { | 1392 if (var->mode() == DYNAMIC_GLOBAL) { |
1386 EmitLoadGlobalCheckExtensions(var, typeof_state, slow); | 1393 EmitLoadGlobalCheckExtensions(var, typeof_state, slow); |
1387 __ jmp(done); | 1394 __ jmp(done); |
1388 } else if (var->mode() == DYNAMIC_LOCAL) { | 1395 } else if (var->mode() == DYNAMIC_LOCAL) { |
1389 Variable* local = var->local_if_not_shadowed(); | 1396 Variable* local = var->local_if_not_shadowed(); |
1390 __ ldr(r0, ContextSlotOperandCheckExtensions(local, slow)); | 1397 __ ldr(r0, ContextSlotOperandCheckExtensions(local, slow)); |
1391 if (local->mode() == CONST || | 1398 if (local->mode() == LET || |
1392 local->mode() == CONST_HARMONY || | 1399 local->mode() == CONST || |
1393 local->mode() == LET) { | 1400 local->mode() == CONST_HARMONY) { |
1394 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); | 1401 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); |
1395 if (local->mode() == CONST) { | 1402 if (local->mode() == CONST) { |
1396 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex, eq); | 1403 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex, eq); |
1397 } else { // LET || CONST_HARMONY | 1404 } else { // LET || CONST_HARMONY |
1398 __ b(ne, done); | 1405 __ b(ne, done); |
1399 __ mov(r0, Operand(var->name())); | 1406 __ mov(r0, Operand(var->name())); |
1400 __ push(r0); | 1407 __ push(r0); |
1401 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 1408 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
1402 } | 1409 } |
1403 } | 1410 } |
(...skipping 3125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4529 *context_length = 0; | 4536 *context_length = 0; |
4530 return previous_; | 4537 return previous_; |
4531 } | 4538 } |
4532 | 4539 |
4533 | 4540 |
4534 #undef __ | 4541 #undef __ |
4535 | 4542 |
4536 } } // namespace v8::internal | 4543 } } // namespace v8::internal |
4537 | 4544 |
4538 #endif // V8_TARGET_ARCH_ARM | 4545 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |