| 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 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 | 1337 |
| 1338 // All extension objects were empty and it is safe to use a global | 1338 // All extension objects were empty and it is safe to use a global |
| 1339 // load IC call. | 1339 // load IC call. |
| 1340 __ mov(LoadIC::ReceiverRegister(), GlobalObjectOperand()); | 1340 __ mov(LoadIC::ReceiverRegister(), GlobalObjectOperand()); |
| 1341 __ mov(LoadIC::NameRegister(), proxy->var()->name()); | 1341 __ mov(LoadIC::NameRegister(), proxy->var()->name()); |
| 1342 if (FLAG_vector_ics) { | 1342 if (FLAG_vector_ics) { |
| 1343 __ mov(LoadIC::SlotRegister(), | 1343 __ mov(LoadIC::SlotRegister(), |
| 1344 Immediate(Smi::FromInt(proxy->VariableFeedbackSlot()))); | 1344 Immediate(Smi::FromInt(proxy->VariableFeedbackSlot()))); |
| 1345 } | 1345 } |
| 1346 | 1346 |
| 1347 ContextualMode mode = (typeof_state == INSIDE_TYPEOF) | 1347 CallLoadIC(typeof_state); |
| 1348 ? NOT_CONTEXTUAL | |
| 1349 : CONTEXTUAL; | |
| 1350 | |
| 1351 CallLoadIC(mode); | |
| 1352 } | 1348 } |
| 1353 | 1349 |
| 1354 | 1350 |
| 1355 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, | 1351 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, |
| 1356 Label* slow) { | 1352 Label* slow) { |
| 1357 ASSERT(var->IsContextSlot()); | 1353 ASSERT(var->IsContextSlot()); |
| 1358 Register context = esi; | 1354 Register context = esi; |
| 1359 Register temp = ebx; | 1355 Register temp = ebx; |
| 1360 | 1356 |
| 1361 for (Scope* s = scope(); s != var->scope(); s = s->outer_scope()) { | 1357 for (Scope* s = scope(); s != var->scope(); s = s->outer_scope()) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1423 // variables. | 1419 // variables. |
| 1424 switch (var->location()) { | 1420 switch (var->location()) { |
| 1425 case Variable::UNALLOCATED: { | 1421 case Variable::UNALLOCATED: { |
| 1426 Comment cmnt(masm_, "[ Global variable"); | 1422 Comment cmnt(masm_, "[ Global variable"); |
| 1427 __ mov(LoadIC::ReceiverRegister(), GlobalObjectOperand()); | 1423 __ mov(LoadIC::ReceiverRegister(), GlobalObjectOperand()); |
| 1428 __ mov(LoadIC::NameRegister(), var->name()); | 1424 __ mov(LoadIC::NameRegister(), var->name()); |
| 1429 if (FLAG_vector_ics) { | 1425 if (FLAG_vector_ics) { |
| 1430 __ mov(LoadIC::SlotRegister(), | 1426 __ mov(LoadIC::SlotRegister(), |
| 1431 Immediate(Smi::FromInt(proxy->VariableFeedbackSlot()))); | 1427 Immediate(Smi::FromInt(proxy->VariableFeedbackSlot()))); |
| 1432 } | 1428 } |
| 1433 CallLoadIC(CONTEXTUAL); | 1429 CallLoadIC(NOT_INSIDE_TYPEOF); |
| 1434 context()->Plug(eax); | 1430 context()->Plug(eax); |
| 1435 break; | 1431 break; |
| 1436 } | 1432 } |
| 1437 | 1433 |
| 1438 case Variable::PARAMETER: | 1434 case Variable::PARAMETER: |
| 1439 case Variable::LOCAL: | 1435 case Variable::LOCAL: |
| 1440 case Variable::CONTEXT: { | 1436 case Variable::CONTEXT: { |
| 1441 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" | 1437 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" |
| 1442 : "[ Stack variable"); | 1438 : "[ Stack variable"); |
| 1443 if (var->binding_needs_init()) { | 1439 if (var->binding_needs_init()) { |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2049 // if (!result.done) goto l_try; | 2045 // if (!result.done) goto l_try; |
| 2050 __ bind(&l_loop); | 2046 __ bind(&l_loop); |
| 2051 __ push(eax); // save result | 2047 __ push(eax); // save result |
| 2052 __ Move(load_receiver, eax); // result | 2048 __ Move(load_receiver, eax); // result |
| 2053 __ mov(load_name, | 2049 __ mov(load_name, |
| 2054 isolate()->factory()->done_string()); // "done" | 2050 isolate()->factory()->done_string()); // "done" |
| 2055 if (FLAG_vector_ics) { | 2051 if (FLAG_vector_ics) { |
| 2056 __ mov(LoadIC::SlotRegister(), | 2052 __ mov(LoadIC::SlotRegister(), |
| 2057 Immediate(Smi::FromInt(expr->DoneFeedbackSlot()))); | 2053 Immediate(Smi::FromInt(expr->DoneFeedbackSlot()))); |
| 2058 } | 2054 } |
| 2059 CallLoadIC(NOT_CONTEXTUAL); // result.done in eax | 2055 CallLoadIC(); // result.done in eax |
| 2060 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); | 2056 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); |
| 2061 CallIC(bool_ic); | 2057 CallIC(bool_ic); |
| 2062 __ test(eax, eax); | 2058 __ test(eax, eax); |
| 2063 __ j(zero, &l_try); | 2059 __ j(zero, &l_try); |
| 2064 | 2060 |
| 2065 // result.value | 2061 // result.value |
| 2066 __ pop(load_receiver); // result | 2062 __ pop(load_receiver); // result |
| 2067 __ mov(load_name, | 2063 __ mov(load_name, |
| 2068 isolate()->factory()->value_string()); // "value" | 2064 isolate()->factory()->value_string()); // "value" |
| 2069 if (FLAG_vector_ics) { | 2065 if (FLAG_vector_ics) { |
| 2070 __ mov(LoadIC::SlotRegister(), | 2066 __ mov(LoadIC::SlotRegister(), |
| 2071 Immediate(Smi::FromInt(expr->ValueFeedbackSlot()))); | 2067 Immediate(Smi::FromInt(expr->ValueFeedbackSlot()))); |
| 2072 } | 2068 } |
| 2073 CallLoadIC(NOT_CONTEXTUAL); // result.value in eax | 2069 CallLoadIC(); // result.value in eax |
| 2074 context()->DropAndPlug(2, eax); // drop iter and g | 2070 context()->DropAndPlug(2, eax); // drop iter and g |
| 2075 break; | 2071 break; |
| 2076 } | 2072 } |
| 2077 } | 2073 } |
| 2078 } | 2074 } |
| 2079 | 2075 |
| 2080 | 2076 |
| 2081 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 2077 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
| 2082 Expression *value, | 2078 Expression *value, |
| 2083 JSGeneratorObject::ResumeMode resume_mode) { | 2079 JSGeneratorObject::ResumeMode resume_mode) { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2226 | 2222 |
| 2227 | 2223 |
| 2228 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { | 2224 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
| 2229 SetSourcePosition(prop->position()); | 2225 SetSourcePosition(prop->position()); |
| 2230 Literal* key = prop->key()->AsLiteral(); | 2226 Literal* key = prop->key()->AsLiteral(); |
| 2231 ASSERT(!key->value()->IsSmi()); | 2227 ASSERT(!key->value()->IsSmi()); |
| 2232 __ mov(LoadIC::NameRegister(), Immediate(key->value())); | 2228 __ mov(LoadIC::NameRegister(), Immediate(key->value())); |
| 2233 if (FLAG_vector_ics) { | 2229 if (FLAG_vector_ics) { |
| 2234 __ mov(LoadIC::SlotRegister(), | 2230 __ mov(LoadIC::SlotRegister(), |
| 2235 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); | 2231 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); |
| 2236 CallLoadIC(NOT_CONTEXTUAL); | 2232 CallLoadIC(INSIDE_TYPEOF); |
| 2237 } else { | 2233 } else { |
| 2238 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); | 2234 CallLoadIC(INSIDE_TYPEOF, prop->PropertyFeedbackId()); |
| 2239 } | 2235 } |
| 2240 } | 2236 } |
| 2241 | 2237 |
| 2242 | 2238 |
| 2243 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2239 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
| 2244 SetSourcePosition(prop->position()); | 2240 SetSourcePosition(prop->position()); |
| 2245 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | 2241 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); |
| 2246 if (FLAG_vector_ics) { | 2242 if (FLAG_vector_ics) { |
| 2247 __ mov(LoadIC::SlotRegister(), | 2243 __ mov(LoadIC::SlotRegister(), |
| 2248 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); | 2244 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); |
| (...skipping 1803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4052 // Push the builtins object as receiver. | 4048 // Push the builtins object as receiver. |
| 4053 __ mov(eax, GlobalObjectOperand()); | 4049 __ mov(eax, GlobalObjectOperand()); |
| 4054 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset)); | 4050 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset)); |
| 4055 | 4051 |
| 4056 // Load the function from the receiver. | 4052 // Load the function from the receiver. |
| 4057 __ mov(LoadIC::ReceiverRegister(), Operand(esp, 0)); | 4053 __ mov(LoadIC::ReceiverRegister(), Operand(esp, 0)); |
| 4058 __ mov(LoadIC::NameRegister(), Immediate(expr->name())); | 4054 __ mov(LoadIC::NameRegister(), Immediate(expr->name())); |
| 4059 if (FLAG_vector_ics) { | 4055 if (FLAG_vector_ics) { |
| 4060 __ mov(LoadIC::SlotRegister(), | 4056 __ mov(LoadIC::SlotRegister(), |
| 4061 Immediate(Smi::FromInt(expr->CallRuntimeFeedbackSlot()))); | 4057 Immediate(Smi::FromInt(expr->CallRuntimeFeedbackSlot()))); |
| 4062 CallLoadIC(NOT_CONTEXTUAL); | 4058 CallLoadIC(INSIDE_TYPEOF); |
| 4063 } else { | 4059 } else { |
| 4064 CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId()); | 4060 CallLoadIC(INSIDE_TYPEOF, expr->CallRuntimeFeedbackId()); |
| 4065 } | 4061 } |
| 4066 | 4062 |
| 4067 // Push the target function under the receiver. | 4063 // Push the target function under the receiver. |
| 4068 __ push(Operand(esp, 0)); | 4064 __ push(Operand(esp, 0)); |
| 4069 __ mov(Operand(esp, kPointerSize), eax); | 4065 __ mov(Operand(esp, kPointerSize), eax); |
| 4070 | 4066 |
| 4071 // Code common for calls using the IC. | 4067 // Code common for calls using the IC. |
| 4072 ZoneList<Expression*>* args = expr->arguments(); | 4068 ZoneList<Expression*>* args = expr->arguments(); |
| 4073 int arg_count = args->length(); | 4069 int arg_count = args->length(); |
| 4074 for (int i = 0; i < arg_count; i++) { | 4070 for (int i = 0; i < arg_count; i++) { |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4407 ASSERT(!context()->IsTest()); | 4403 ASSERT(!context()->IsTest()); |
| 4408 | 4404 |
| 4409 if (proxy != NULL && proxy->var()->IsUnallocated()) { | 4405 if (proxy != NULL && proxy->var()->IsUnallocated()) { |
| 4410 Comment cmnt(masm_, "[ Global variable"); | 4406 Comment cmnt(masm_, "[ Global variable"); |
| 4411 __ mov(LoadIC::ReceiverRegister(), GlobalObjectOperand()); | 4407 __ mov(LoadIC::ReceiverRegister(), GlobalObjectOperand()); |
| 4412 __ mov(LoadIC::NameRegister(), Immediate(proxy->name())); | 4408 __ mov(LoadIC::NameRegister(), Immediate(proxy->name())); |
| 4413 if (FLAG_vector_ics) { | 4409 if (FLAG_vector_ics) { |
| 4414 __ mov(LoadIC::SlotRegister(), | 4410 __ mov(LoadIC::SlotRegister(), |
| 4415 Immediate(Smi::FromInt(proxy->VariableFeedbackSlot()))); | 4411 Immediate(Smi::FromInt(proxy->VariableFeedbackSlot()))); |
| 4416 } | 4412 } |
| 4417 // Use a regular load, not a contextual load, to avoid a reference | 4413 // We don't want a reference error if the load fails on the global object. |
| 4418 // error. | 4414 CallLoadIC(INSIDE_TYPEOF); |
| 4419 CallLoadIC(NOT_CONTEXTUAL); | |
| 4420 PrepareForBailout(expr, TOS_REG); | 4415 PrepareForBailout(expr, TOS_REG); |
| 4421 context()->Plug(eax); | 4416 context()->Plug(eax); |
| 4422 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { | 4417 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { |
| 4423 Comment cmnt(masm_, "[ Lookup slot"); | 4418 Comment cmnt(masm_, "[ Lookup slot"); |
| 4424 Label done, slow; | 4419 Label done, slow; |
| 4425 | 4420 |
| 4426 // Generate code for loading from variables potentially shadowed | 4421 // Generate code for loading from variables potentially shadowed |
| 4427 // by eval-introduced variables. | 4422 // by eval-introduced variables. |
| 4428 EmitDynamicLookupFastCase(proxy, INSIDE_TYPEOF, &slow, &done); | 4423 EmitDynamicLookupFastCase(proxy, INSIDE_TYPEOF, &slow, &done); |
| 4429 | 4424 |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4834 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4829 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 4835 Assembler::target_address_at(call_target_address, | 4830 Assembler::target_address_at(call_target_address, |
| 4836 unoptimized_code)); | 4831 unoptimized_code)); |
| 4837 return OSR_AFTER_STACK_CHECK; | 4832 return OSR_AFTER_STACK_CHECK; |
| 4838 } | 4833 } |
| 4839 | 4834 |
| 4840 | 4835 |
| 4841 } } // namespace v8::internal | 4836 } } // namespace v8::internal |
| 4842 | 4837 |
| 4843 #endif // V8_TARGET_ARCH_IA32 | 4838 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |