| 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 2438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2449 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 2449 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
| 2450 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 2450 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
| 2451 CallIC(ic); | 2451 CallIC(ic); |
| 2452 break; | 2452 break; |
| 2453 } | 2453 } |
| 2454 } | 2454 } |
| 2455 context()->Plug(r0); | 2455 context()->Plug(r0); |
| 2456 } | 2456 } |
| 2457 | 2457 |
| 2458 | 2458 |
| 2459 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( |
| 2460 Variable* var, MemOperand location) { |
| 2461 __ str(result_register(), location); |
| 2462 if (var->IsContextSlot()) { |
| 2463 // RecordWrite may destroy all its register arguments. |
| 2464 __ mov(r3, result_register()); |
| 2465 int offset = Context::SlotOffset(var->index()); |
| 2466 __ RecordWriteContextSlot( |
| 2467 r1, offset, r3, r2, kLRHasBeenSaved, kDontSaveFPRegs); |
| 2468 } |
| 2469 } |
| 2470 |
| 2471 |
| 2472 void FullCodeGenerator::EmitCallStoreContextSlot( |
| 2473 Handle<String> name, LanguageMode mode) { |
| 2474 __ push(r0); // Value. |
| 2475 __ mov(r1, Operand(name)); |
| 2476 __ mov(r0, Operand(Smi::FromInt(mode))); |
| 2477 __ Push(cp, r1, r0); // Context, name, strict mode. |
| 2478 __ CallRuntime(Runtime::kStoreContextSlot, 4); |
| 2479 } |
| 2480 |
| 2481 |
| 2459 void FullCodeGenerator::EmitVariableAssignment(Variable* var, | 2482 void FullCodeGenerator::EmitVariableAssignment(Variable* var, |
| 2460 Token::Value op) { | 2483 Token::Value op) { |
| 2461 if (var->IsUnallocated()) { | 2484 if (var->IsUnallocated()) { |
| 2462 // Global var, const, or let. | 2485 // Global var, const, or let. |
| 2463 __ mov(r2, Operand(var->name())); | 2486 __ mov(r2, Operand(var->name())); |
| 2464 __ ldr(r1, GlobalObjectOperand()); | 2487 __ ldr(r1, GlobalObjectOperand()); |
| 2465 CallStoreIC(); | 2488 CallStoreIC(); |
| 2489 |
| 2466 } else if (op == Token::INIT_CONST) { | 2490 } else if (op == Token::INIT_CONST) { |
| 2467 // Const initializers need a write barrier. | 2491 // Const initializers need a write barrier. |
| 2468 ASSERT(!var->IsParameter()); // No const parameters. | 2492 ASSERT(!var->IsParameter()); // No const parameters. |
| 2469 if (var->IsStackLocal()) { | 2493 if (var->IsLookupSlot()) { |
| 2470 __ ldr(r1, StackOperand(var)); | |
| 2471 __ CompareRoot(r1, Heap::kTheHoleValueRootIndex); | |
| 2472 __ str(result_register(), StackOperand(var), eq); | |
| 2473 } else { | |
| 2474 ASSERT(var->IsContextSlot() || var->IsLookupSlot()); | |
| 2475 // Like var declarations, const declarations are hoisted to function | |
| 2476 // scope. However, unlike var initializers, const initializers are | |
| 2477 // able to drill a hole to that function context, even from inside a | |
| 2478 // 'with' context. We thus bypass the normal static scope lookup for | |
| 2479 // var->IsContextSlot(). | |
| 2480 __ push(r0); | 2494 __ push(r0); |
| 2481 __ mov(r0, Operand(var->name())); | 2495 __ mov(r0, Operand(var->name())); |
| 2482 __ Push(cp, r0); // Context and name. | 2496 __ Push(cp, r0); // Context and name. |
| 2483 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); | 2497 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); |
| 2498 } else { |
| 2499 ASSERT(var->IsStackAllocated() || var->IsContextSlot()); |
| 2500 Label skip; |
| 2501 MemOperand location = VarOperand(var, r1); |
| 2502 __ ldr(r2, location); |
| 2503 __ CompareRoot(r2, Heap::kTheHoleValueRootIndex); |
| 2504 __ b(ne, &skip); |
| 2505 EmitStoreToStackLocalOrContextSlot(var, location); |
| 2506 __ bind(&skip); |
| 2484 } | 2507 } |
| 2485 | 2508 |
| 2486 } else if (var->mode() == LET && op != Token::INIT_LET) { | 2509 } else if (var->mode() == LET && op != Token::INIT_LET) { |
| 2487 // Non-initializing assignment to let variable needs a write barrier. | 2510 // Non-initializing assignment to let variable needs a write barrier. |
| 2488 if (var->IsLookupSlot()) { | 2511 if (var->IsLookupSlot()) { |
| 2489 __ push(r0); // Value. | 2512 EmitCallStoreContextSlot(var->name(), language_mode()); |
| 2490 __ mov(r1, Operand(var->name())); | |
| 2491 __ mov(r0, Operand(Smi::FromInt(language_mode()))); | |
| 2492 __ Push(cp, r1, r0); // Context, name, strict mode. | |
| 2493 __ CallRuntime(Runtime::kStoreContextSlot, 4); | |
| 2494 } else { | 2513 } else { |
| 2495 ASSERT(var->IsStackAllocated() || var->IsContextSlot()); | 2514 ASSERT(var->IsStackAllocated() || var->IsContextSlot()); |
| 2496 Label assign; | 2515 Label assign; |
| 2497 MemOperand location = VarOperand(var, r1); | 2516 MemOperand location = VarOperand(var, r1); |
| 2498 __ ldr(r3, location); | 2517 __ ldr(r3, location); |
| 2499 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); | 2518 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); |
| 2500 __ b(ne, &assign); | 2519 __ b(ne, &assign); |
| 2501 __ mov(r3, Operand(var->name())); | 2520 __ mov(r3, Operand(var->name())); |
| 2502 __ push(r3); | 2521 __ push(r3); |
| 2503 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 2522 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
| 2504 // Perform the assignment. | 2523 // Perform the assignment. |
| 2505 __ bind(&assign); | 2524 __ bind(&assign); |
| 2506 __ str(result_register(), location); | 2525 EmitStoreToStackLocalOrContextSlot(var, location); |
| 2507 if (var->IsContextSlot()) { | |
| 2508 // RecordWrite may destroy all its register arguments. | |
| 2509 __ mov(r3, result_register()); | |
| 2510 int offset = Context::SlotOffset(var->index()); | |
| 2511 __ RecordWriteContextSlot( | |
| 2512 r1, offset, r3, r2, kLRHasBeenSaved, kDontSaveFPRegs); | |
| 2513 } | |
| 2514 } | 2526 } |
| 2515 | 2527 |
| 2516 } else if (!var->is_const_mode() || op == Token::INIT_CONST_HARMONY) { | 2528 } else if (!var->is_const_mode() || op == Token::INIT_CONST_HARMONY) { |
| 2517 // Assignment to var or initializing assignment to let/const | 2529 // Assignment to var or initializing assignment to let/const |
| 2518 // in harmony mode. | 2530 // in harmony mode. |
| 2519 if (var->IsStackAllocated() || var->IsContextSlot()) { | 2531 if (var->IsLookupSlot()) { |
| 2532 EmitCallStoreContextSlot(var->name(), language_mode()); |
| 2533 } else { |
| 2534 ASSERT((var->IsStackAllocated() || var->IsContextSlot())); |
| 2520 MemOperand location = VarOperand(var, r1); | 2535 MemOperand location = VarOperand(var, r1); |
| 2521 if (generate_debug_code_ && op == Token::INIT_LET) { | 2536 if (generate_debug_code_ && op == Token::INIT_LET) { |
| 2522 // Check for an uninitialized let binding. | 2537 // Check for an uninitialized let binding. |
| 2523 __ ldr(r2, location); | 2538 __ ldr(r2, location); |
| 2524 __ CompareRoot(r2, Heap::kTheHoleValueRootIndex); | 2539 __ CompareRoot(r2, Heap::kTheHoleValueRootIndex); |
| 2525 __ Check(eq, kLetBindingReInitialization); | 2540 __ Check(eq, kLetBindingReInitialization); |
| 2526 } | 2541 } |
| 2527 // Perform the assignment. | 2542 EmitStoreToStackLocalOrContextSlot(var, location); |
| 2528 __ str(r0, location); | |
| 2529 if (var->IsContextSlot()) { | |
| 2530 __ mov(r3, r0); | |
| 2531 int offset = Context::SlotOffset(var->index()); | |
| 2532 __ RecordWriteContextSlot( | |
| 2533 r1, offset, r3, r2, kLRHasBeenSaved, kDontSaveFPRegs); | |
| 2534 } | |
| 2535 } else { | |
| 2536 ASSERT(var->IsLookupSlot()); | |
| 2537 __ push(r0); // Value. | |
| 2538 __ mov(r1, Operand(var->name())); | |
| 2539 __ mov(r0, Operand(Smi::FromInt(language_mode()))); | |
| 2540 __ Push(cp, r1, r0); // Context, name, strict mode. | |
| 2541 __ CallRuntime(Runtime::kStoreContextSlot, 4); | |
| 2542 } | 2543 } |
| 2543 } | 2544 } |
| 2544 // Non-initializing assignments to consts are ignored. | 2545 // Non-initializing assignments to consts are ignored. |
| 2545 } | 2546 } |
| 2546 | 2547 |
| 2547 | 2548 |
| 2548 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { | 2549 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
| 2549 // Assignment to a property, using a named store IC. | 2550 // Assignment to a property, using a named store IC. |
| 2550 Property* prop = expr->target()->AsProperty(); | 2551 Property* prop = expr->target()->AsProperty(); |
| 2551 ASSERT(prop != NULL); | 2552 ASSERT(prop != NULL); |
| (...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4917 ASSERT(Memory::uint32_at(interrupt_address_pointer) == | 4918 ASSERT(Memory::uint32_at(interrupt_address_pointer) == |
| 4918 reinterpret_cast<uint32_t>( | 4919 reinterpret_cast<uint32_t>( |
| 4919 isolate->builtins()->OsrAfterStackCheck()->entry())); | 4920 isolate->builtins()->OsrAfterStackCheck()->entry())); |
| 4920 return OSR_AFTER_STACK_CHECK; | 4921 return OSR_AFTER_STACK_CHECK; |
| 4921 } | 4922 } |
| 4922 | 4923 |
| 4923 | 4924 |
| 4924 } } // namespace v8::internal | 4925 } } // namespace v8::internal |
| 4925 | 4926 |
| 4926 #endif // V8_TARGET_ARCH_ARM | 4927 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |