OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 context()->Plug(eax); | 1270 context()->Plug(eax); |
1271 } | 1271 } |
1272 | 1272 |
1273 | 1273 |
1274 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { | 1274 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { |
1275 Comment cmnt(masm_, "[ VariableProxy"); | 1275 Comment cmnt(masm_, "[ VariableProxy"); |
1276 EmitVariableLoad(expr); | 1276 EmitVariableLoad(expr); |
1277 } | 1277 } |
1278 | 1278 |
1279 | 1279 |
| 1280 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { |
| 1281 Comment cnmt(masm_, "[ SuperReference "); |
| 1282 |
| 1283 __ mov(LoadConvention::ReceiverRegister(), |
| 1284 Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1285 |
| 1286 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol()); |
| 1287 __ mov(LoadConvention::NameRegister(), home_object_symbol); |
| 1288 |
| 1289 CallLoadIC(NOT_CONTEXTUAL, expr->HomeObjectFeedbackId()); |
| 1290 |
| 1291 __ cmp(eax, isolate()->factory()->undefined_value()); |
| 1292 Label done; |
| 1293 __ j(not_equal, &done); |
| 1294 __ CallRuntime(Runtime::kThrowNonMethodError, 0); |
| 1295 __ bind(&done); |
| 1296 } |
| 1297 |
| 1298 |
1280 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, | 1299 void FullCodeGenerator::EmitLoadGlobalCheckExtensions(VariableProxy* proxy, |
1281 TypeofState typeof_state, | 1300 TypeofState typeof_state, |
1282 Label* slow) { | 1301 Label* slow) { |
1283 Register context = esi; | 1302 Register context = esi; |
1284 Register temp = edx; | 1303 Register temp = edx; |
1285 | 1304 |
1286 Scope* s = scope(); | 1305 Scope* s = scope(); |
1287 while (s != NULL) { | 1306 while (s != NULL) { |
1288 if (s->num_heap_slots() > 0) { | 1307 if (s->num_heap_slots() > 0) { |
1289 if (s->calls_sloppy_eval()) { | 1308 if (s->calls_sloppy_eval()) { |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2212 // root set. | 2231 // root set. |
2213 __ RecordWriteField(eax, JSGeneratorObject::kResultValuePropertyOffset, | 2232 __ RecordWriteField(eax, JSGeneratorObject::kResultValuePropertyOffset, |
2214 ecx, edx, kDontSaveFPRegs); | 2233 ecx, edx, kDontSaveFPRegs); |
2215 } | 2234 } |
2216 | 2235 |
2217 | 2236 |
2218 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { | 2237 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
2219 SetSourcePosition(prop->position()); | 2238 SetSourcePosition(prop->position()); |
2220 Literal* key = prop->key()->AsLiteral(); | 2239 Literal* key = prop->key()->AsLiteral(); |
2221 DCHECK(!key->value()->IsSmi()); | 2240 DCHECK(!key->value()->IsSmi()); |
| 2241 |
| 2242 if (prop->IsSuperAccess()) { |
| 2243 SuperReference* super_ref = prop->obj()->AsSuperReference(); |
| 2244 EmitLoadHomeObject(super_ref); |
| 2245 __ push(eax); |
| 2246 VisitForStackValue(super_ref->this_var()); |
| 2247 __ push(Immediate(key->value())); |
| 2248 __ CallRuntime(Runtime::kLoadFromSuper, 3); |
| 2249 return; |
| 2250 } |
| 2251 |
2222 __ mov(LoadConvention::NameRegister(), Immediate(key->value())); | 2252 __ mov(LoadConvention::NameRegister(), Immediate(key->value())); |
2223 if (FLAG_vector_ics) { | 2253 if (FLAG_vector_ics) { |
2224 __ mov(VectorLoadConvention::SlotRegister(), | 2254 __ mov(VectorLoadConvention::SlotRegister(), |
2225 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); | 2255 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); |
2226 CallLoadIC(NOT_CONTEXTUAL); | 2256 CallLoadIC(NOT_CONTEXTUAL); |
2227 } else { | 2257 } else { |
2228 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); | 2258 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); |
2229 } | 2259 } |
2230 } | 2260 } |
2231 | 2261 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2515 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2545 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2516 context()->Plug(eax); | 2546 context()->Plug(eax); |
2517 } | 2547 } |
2518 | 2548 |
2519 | 2549 |
2520 void FullCodeGenerator::VisitProperty(Property* expr) { | 2550 void FullCodeGenerator::VisitProperty(Property* expr) { |
2521 Comment cmnt(masm_, "[ Property"); | 2551 Comment cmnt(masm_, "[ Property"); |
2522 Expression* key = expr->key(); | 2552 Expression* key = expr->key(); |
2523 | 2553 |
2524 if (key->IsPropertyName()) { | 2554 if (key->IsPropertyName()) { |
2525 VisitForAccumulatorValue(expr->obj()); | 2555 if (!expr->IsSuperAccess()) { |
2526 __ Move(LoadConvention::ReceiverRegister(), result_register()); | 2556 VisitForAccumulatorValue(expr->obj()); |
| 2557 __ Move(LoadConvention::ReceiverRegister(), result_register()); |
| 2558 } |
2527 EmitNamedPropertyLoad(expr); | 2559 EmitNamedPropertyLoad(expr); |
2528 PrepareForBailoutForId(expr->LoadId(), TOS_REG); | 2560 PrepareForBailoutForId(expr->LoadId(), TOS_REG); |
2529 context()->Plug(eax); | 2561 context()->Plug(eax); |
2530 } else { | 2562 } else { |
2531 VisitForStackValue(expr->obj()); | 2563 VisitForStackValue(expr->obj()); |
2532 VisitForAccumulatorValue(expr->key()); | 2564 VisitForAccumulatorValue(expr->key()); |
2533 __ pop(LoadConvention::ReceiverRegister()); // Object. | 2565 __ pop(LoadConvention::ReceiverRegister()); // Object. |
2534 __ Move(LoadConvention::NameRegister(), result_register()); // Key. | 2566 __ Move(LoadConvention::NameRegister(), result_register()); // Key. |
2535 EmitKeyedPropertyLoad(expr); | 2567 EmitKeyedPropertyLoad(expr); |
2536 context()->Plug(eax); | 2568 context()->Plug(eax); |
(...skipping 17 matching lines...) Expand all Loading... |
2554 : CallIC::METHOD; | 2586 : CallIC::METHOD; |
2555 // Get the target function. | 2587 // Get the target function. |
2556 if (call_type == CallIC::FUNCTION) { | 2588 if (call_type == CallIC::FUNCTION) { |
2557 { StackValueContext context(this); | 2589 { StackValueContext context(this); |
2558 EmitVariableLoad(callee->AsVariableProxy()); | 2590 EmitVariableLoad(callee->AsVariableProxy()); |
2559 PrepareForBailout(callee, NO_REGISTERS); | 2591 PrepareForBailout(callee, NO_REGISTERS); |
2560 } | 2592 } |
2561 // Push undefined as receiver. This is patched in the method prologue if it | 2593 // Push undefined as receiver. This is patched in the method prologue if it |
2562 // is a sloppy mode method. | 2594 // is a sloppy mode method. |
2563 __ push(Immediate(isolate()->factory()->undefined_value())); | 2595 __ push(Immediate(isolate()->factory()->undefined_value())); |
| 2596 } else if (callee->AsProperty()->IsSuperAccess()) { |
| 2597 Property* prop = callee->AsProperty(); |
| 2598 SetSourcePosition(prop->position()); |
| 2599 Literal* key = prop->key()->AsLiteral(); |
| 2600 DCHECK(!key->value()->IsSmi()); |
| 2601 // Load the function from the receiver. |
| 2602 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference(); |
| 2603 EmitLoadHomeObject(super_ref); |
| 2604 __ push(eax); |
| 2605 VisitForAccumulatorValue(super_ref->this_var()); |
| 2606 __ push(eax); |
| 2607 __ push(Operand(esp, kPointerSize)); |
| 2608 __ push(eax); |
| 2609 __ push(Immediate(key->value())); |
| 2610 __ CallRuntime(Runtime::kLoadFromSuper, 3); |
| 2611 __ mov(Operand(esp, kPointerSize), eax); |
2564 } else { | 2612 } else { |
2565 // Load the function from the receiver. | 2613 // Load the function from the receiver. |
2566 DCHECK(callee->IsProperty()); | 2614 DCHECK(callee->IsProperty()); |
2567 __ mov(LoadConvention::ReceiverRegister(), Operand(esp, 0)); | 2615 __ mov(LoadConvention::ReceiverRegister(), Operand(esp, 0)); |
2568 EmitNamedPropertyLoad(callee->AsProperty()); | 2616 EmitNamedPropertyLoad(callee->AsProperty()); |
2569 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2617 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
2570 // Push the target function under the receiver. | 2618 // Push the target function under the receiver. |
2571 __ push(Operand(esp, 0)); | 2619 __ push(Operand(esp, 0)); |
2572 __ mov(Operand(esp, kPointerSize), eax); | 2620 __ mov(Operand(esp, kPointerSize), eax); |
2573 } | 2621 } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2729 __ push(Immediate(isolate()->factory()->undefined_value())); | 2777 __ push(Immediate(isolate()->factory()->undefined_value())); |
2730 __ bind(&call); | 2778 __ bind(&call); |
2731 } | 2779 } |
2732 | 2780 |
2733 // The receiver is either the global receiver or an object found by | 2781 // The receiver is either the global receiver or an object found by |
2734 // LoadContextSlot. | 2782 // LoadContextSlot. |
2735 EmitCall(expr); | 2783 EmitCall(expr); |
2736 | 2784 |
2737 } else if (call_type == Call::PROPERTY_CALL) { | 2785 } else if (call_type == Call::PROPERTY_CALL) { |
2738 Property* property = callee->AsProperty(); | 2786 Property* property = callee->AsProperty(); |
2739 { PreservePositionScope scope(masm()->positions_recorder()); | 2787 bool is_named_call = property->key()->IsPropertyName(); |
| 2788 // super.x() is handled in EmitCallWithLoadIC. |
| 2789 if (!property->IsSuperAccess() || !is_named_call) { |
| 2790 PreservePositionScope scope(masm()->positions_recorder()); |
2740 VisitForStackValue(property->obj()); | 2791 VisitForStackValue(property->obj()); |
2741 } | 2792 } |
2742 if (property->key()->IsPropertyName()) { | 2793 if (is_named_call) { |
2743 EmitCallWithLoadIC(expr); | 2794 EmitCallWithLoadIC(expr); |
2744 } else { | 2795 } else { |
2745 EmitKeyedCallWithLoadIC(expr, property->key()); | 2796 EmitKeyedCallWithLoadIC(expr, property->key()); |
2746 } | 2797 } |
2747 | 2798 |
2748 } else { | 2799 } else { |
2749 DCHECK(call_type == Call::OTHER_CALL); | 2800 DCHECK(call_type == Call::OTHER_CALL); |
2750 // Call to an arbitrary expression not handled specially above. | 2801 // Call to an arbitrary expression not handled specially above. |
2751 { PreservePositionScope scope(masm()->positions_recorder()); | 2802 { PreservePositionScope scope(masm()->positions_recorder()); |
2752 VisitForStackValue(callee); | 2803 VisitForStackValue(callee); |
(...skipping 2073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4826 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4877 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4827 Assembler::target_address_at(call_target_address, | 4878 Assembler::target_address_at(call_target_address, |
4828 unoptimized_code)); | 4879 unoptimized_code)); |
4829 return OSR_AFTER_STACK_CHECK; | 4880 return OSR_AFTER_STACK_CHECK; |
4830 } | 4881 } |
4831 | 4882 |
4832 | 4883 |
4833 } } // namespace v8::internal | 4884 } } // namespace v8::internal |
4834 | 4885 |
4835 #endif // V8_TARGET_ARCH_IA32 | 4886 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |