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_X87 | 7 #if V8_TARGET_ARCH_X87 |
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 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 | 1246 |
1247 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { | 1247 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { |
1248 Comment cnmt(masm_, "[ SuperReference "); | 1248 Comment cnmt(masm_, "[ SuperReference "); |
1249 | 1249 |
1250 __ mov(LoadDescriptor::ReceiverRegister(), | 1250 __ mov(LoadDescriptor::ReceiverRegister(), |
1251 Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1251 Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
1252 | 1252 |
1253 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol()); | 1253 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol()); |
1254 __ mov(LoadDescriptor::NameRegister(), home_object_symbol); | 1254 __ mov(LoadDescriptor::NameRegister(), home_object_symbol); |
1255 | 1255 |
1256 __ mov(VectorLoadICDescriptor::SlotRegister(), | 1256 __ mov(LoadDescriptor::SlotRegister(), |
1257 Immediate(SmiFromSlot(expr->HomeObjectFeedbackSlot()))); | 1257 Immediate(SmiFromSlot(expr->HomeObjectFeedbackSlot()))); |
1258 CallLoadIC(NOT_CONTEXTUAL); | 1258 CallLoadIC(NOT_CONTEXTUAL); |
1259 | 1259 |
1260 __ cmp(eax, isolate()->factory()->undefined_value()); | 1260 __ cmp(eax, isolate()->factory()->undefined_value()); |
1261 Label done; | 1261 Label done; |
1262 __ j(not_equal, &done); | 1262 __ j(not_equal, &done); |
1263 __ CallRuntime(Runtime::kThrowNonMethodError, 0); | 1263 __ CallRuntime(Runtime::kThrowNonMethodError, 0); |
1264 __ bind(&done); | 1264 __ bind(&done); |
1265 } | 1265 } |
1266 | 1266 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 // Load next context in chain. | 1323 // Load next context in chain. |
1324 __ mov(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); | 1324 __ mov(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); |
1325 __ jmp(&next); | 1325 __ jmp(&next); |
1326 __ bind(&fast); | 1326 __ bind(&fast); |
1327 } | 1327 } |
1328 | 1328 |
1329 // All extension objects were empty and it is safe to use a global | 1329 // All extension objects were empty and it is safe to use a global |
1330 // load IC call. | 1330 // load IC call. |
1331 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1331 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1332 __ mov(LoadDescriptor::NameRegister(), proxy->var()->name()); | 1332 __ mov(LoadDescriptor::NameRegister(), proxy->var()->name()); |
1333 __ mov(VectorLoadICDescriptor::SlotRegister(), | 1333 __ mov(LoadDescriptor::SlotRegister(), |
1334 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); | 1334 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
1335 | 1335 |
1336 ContextualMode mode = (typeof_state == INSIDE_TYPEOF) | 1336 ContextualMode mode = (typeof_state == INSIDE_TYPEOF) |
1337 ? NOT_CONTEXTUAL | 1337 ? NOT_CONTEXTUAL |
1338 : CONTEXTUAL; | 1338 : CONTEXTUAL; |
1339 | 1339 |
1340 CallLoadIC(mode); | 1340 CallLoadIC(mode); |
1341 } | 1341 } |
1342 | 1342 |
1343 | 1343 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); | 1409 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); |
1410 Variable* var = proxy->var(); | 1410 Variable* var = proxy->var(); |
1411 | 1411 |
1412 // Three cases: global variables, lookup variables, and all other types of | 1412 // Three cases: global variables, lookup variables, and all other types of |
1413 // variables. | 1413 // variables. |
1414 switch (var->location()) { | 1414 switch (var->location()) { |
1415 case Variable::UNALLOCATED: { | 1415 case Variable::UNALLOCATED: { |
1416 Comment cmnt(masm_, "[ Global variable"); | 1416 Comment cmnt(masm_, "[ Global variable"); |
1417 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1417 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1418 __ mov(LoadDescriptor::NameRegister(), var->name()); | 1418 __ mov(LoadDescriptor::NameRegister(), var->name()); |
1419 __ mov(VectorLoadICDescriptor::SlotRegister(), | 1419 __ mov(LoadDescriptor::SlotRegister(), |
1420 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); | 1420 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
1421 CallGlobalLoadIC(var->name()); | 1421 CallGlobalLoadIC(var->name()); |
1422 context()->Plug(eax); | 1422 context()->Plug(eax); |
1423 break; | 1423 break; |
1424 } | 1424 } |
1425 | 1425 |
1426 case Variable::PARAMETER: | 1426 case Variable::PARAMETER: |
1427 case Variable::LOCAL: | 1427 case Variable::LOCAL: |
1428 case Variable::CONTEXT: { | 1428 case Variable::CONTEXT: { |
1429 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" | 1429 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2102 __ bind(&l_next); | 2102 __ bind(&l_next); |
2103 | 2103 |
2104 __ mov(load_name, isolate()->factory()->next_string()); | 2104 __ mov(load_name, isolate()->factory()->next_string()); |
2105 __ push(load_name); // "next" | 2105 __ push(load_name); // "next" |
2106 __ push(Operand(esp, 2 * kPointerSize)); // iter | 2106 __ push(Operand(esp, 2 * kPointerSize)); // iter |
2107 __ push(eax); // received | 2107 __ push(eax); // received |
2108 | 2108 |
2109 // result = receiver[f](arg); | 2109 // result = receiver[f](arg); |
2110 __ bind(&l_call); | 2110 __ bind(&l_call); |
2111 __ mov(load_receiver, Operand(esp, kPointerSize)); | 2111 __ mov(load_receiver, Operand(esp, kPointerSize)); |
2112 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2112 __ mov(LoadDescriptor::SlotRegister(), |
2113 Immediate(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); | 2113 Immediate(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); |
2114 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 2114 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2115 CallIC(ic, TypeFeedbackId::None()); | 2115 CallIC(ic, TypeFeedbackId::None()); |
2116 __ mov(edi, eax); | 2116 __ mov(edi, eax); |
2117 __ mov(Operand(esp, 2 * kPointerSize), edi); | 2117 __ mov(Operand(esp, 2 * kPointerSize), edi); |
2118 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); | 2118 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); |
2119 __ CallStub(&stub); | 2119 __ CallStub(&stub); |
2120 | 2120 |
2121 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2121 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2122 __ Drop(1); // The function is still on the stack; drop it. | 2122 __ Drop(1); // The function is still on the stack; drop it. |
2123 | 2123 |
2124 // if (!result.done) goto l_try; | 2124 // if (!result.done) goto l_try; |
2125 __ bind(&l_loop); | 2125 __ bind(&l_loop); |
2126 __ push(eax); // save result | 2126 __ push(eax); // save result |
2127 __ Move(load_receiver, eax); // result | 2127 __ Move(load_receiver, eax); // result |
2128 __ mov(load_name, | 2128 __ mov(load_name, |
2129 isolate()->factory()->done_string()); // "done" | 2129 isolate()->factory()->done_string()); // "done" |
2130 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2130 __ mov(LoadDescriptor::SlotRegister(), |
2131 Immediate(SmiFromSlot(expr->DoneFeedbackSlot()))); | 2131 Immediate(SmiFromSlot(expr->DoneFeedbackSlot()))); |
2132 CallLoadIC(NOT_CONTEXTUAL); // result.done in eax | 2132 CallLoadIC(NOT_CONTEXTUAL); // result.done in eax |
2133 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); | 2133 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); |
2134 CallIC(bool_ic); | 2134 CallIC(bool_ic); |
2135 __ test(eax, eax); | 2135 __ test(eax, eax); |
2136 __ j(zero, &l_try); | 2136 __ j(zero, &l_try); |
2137 | 2137 |
2138 // result.value | 2138 // result.value |
2139 __ pop(load_receiver); // result | 2139 __ pop(load_receiver); // result |
2140 __ mov(load_name, | 2140 __ mov(load_name, |
2141 isolate()->factory()->value_string()); // "value" | 2141 isolate()->factory()->value_string()); // "value" |
2142 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2142 __ mov(LoadDescriptor::SlotRegister(), |
2143 Immediate(SmiFromSlot(expr->ValueFeedbackSlot()))); | 2143 Immediate(SmiFromSlot(expr->ValueFeedbackSlot()))); |
2144 CallLoadIC(NOT_CONTEXTUAL); // result.value in eax | 2144 CallLoadIC(NOT_CONTEXTUAL); // result.value in eax |
2145 context()->DropAndPlug(2, eax); // drop iter and g | 2145 context()->DropAndPlug(2, eax); // drop iter and g |
2146 break; | 2146 break; |
2147 } | 2147 } |
2148 } | 2148 } |
2149 } | 2149 } |
2150 | 2150 |
2151 | 2151 |
2152 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 2152 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2271 } | 2271 } |
2272 | 2272 |
2273 | 2273 |
2274 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { | 2274 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
2275 SetSourcePosition(prop->position()); | 2275 SetSourcePosition(prop->position()); |
2276 Literal* key = prop->key()->AsLiteral(); | 2276 Literal* key = prop->key()->AsLiteral(); |
2277 DCHECK(!key->value()->IsSmi()); | 2277 DCHECK(!key->value()->IsSmi()); |
2278 DCHECK(!prop->IsSuperAccess()); | 2278 DCHECK(!prop->IsSuperAccess()); |
2279 | 2279 |
2280 __ mov(LoadDescriptor::NameRegister(), Immediate(key->value())); | 2280 __ mov(LoadDescriptor::NameRegister(), Immediate(key->value())); |
2281 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2281 __ mov(LoadDescriptor::SlotRegister(), |
2282 Immediate(SmiFromSlot(prop->PropertyFeedbackSlot()))); | 2282 Immediate(SmiFromSlot(prop->PropertyFeedbackSlot()))); |
2283 CallLoadIC(NOT_CONTEXTUAL); | 2283 CallLoadIC(NOT_CONTEXTUAL); |
2284 } | 2284 } |
2285 | 2285 |
2286 | 2286 |
2287 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { | 2287 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { |
2288 // Stack: receiver, home_object. | 2288 // Stack: receiver, home_object. |
2289 SetSourcePosition(prop->position()); | 2289 SetSourcePosition(prop->position()); |
2290 Literal* key = prop->key()->AsLiteral(); | 2290 Literal* key = prop->key()->AsLiteral(); |
2291 DCHECK(!key->value()->IsSmi()); | 2291 DCHECK(!key->value()->IsSmi()); |
2292 DCHECK(prop->IsSuperAccess()); | 2292 DCHECK(prop->IsSuperAccess()); |
2293 | 2293 |
2294 __ push(Immediate(key->value())); | 2294 __ push(Immediate(key->value())); |
2295 __ CallRuntime(Runtime::kLoadFromSuper, 3); | 2295 __ CallRuntime(Runtime::kLoadFromSuper, 3); |
2296 } | 2296 } |
2297 | 2297 |
2298 | 2298 |
2299 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2299 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
2300 SetSourcePosition(prop->position()); | 2300 SetSourcePosition(prop->position()); |
2301 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 2301 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2302 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2302 __ mov(LoadDescriptor::SlotRegister(), |
2303 Immediate(SmiFromSlot(prop->PropertyFeedbackSlot()))); | 2303 Immediate(SmiFromSlot(prop->PropertyFeedbackSlot()))); |
2304 CallIC(ic); | 2304 CallIC(ic); |
2305 } | 2305 } |
2306 | 2306 |
2307 | 2307 |
2308 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { | 2308 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { |
2309 // Stack: receiver, home_object, key. | 2309 // Stack: receiver, home_object, key. |
2310 SetSourcePosition(prop->position()); | 2310 SetSourcePosition(prop->position()); |
2311 | 2311 |
2312 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); | 2312 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); |
(...skipping 2204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4517 | 4517 |
4518 | 4518 |
4519 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { | 4519 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
4520 // Push the builtins object as receiver. | 4520 // Push the builtins object as receiver. |
4521 __ mov(eax, GlobalObjectOperand()); | 4521 __ mov(eax, GlobalObjectOperand()); |
4522 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset)); | 4522 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset)); |
4523 | 4523 |
4524 // Load the function from the receiver. | 4524 // Load the function from the receiver. |
4525 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); | 4525 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); |
4526 __ mov(LoadDescriptor::NameRegister(), Immediate(expr->name())); | 4526 __ mov(LoadDescriptor::NameRegister(), Immediate(expr->name())); |
4527 __ mov(VectorLoadICDescriptor::SlotRegister(), | 4527 __ mov(LoadDescriptor::SlotRegister(), |
4528 Immediate(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); | 4528 Immediate(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); |
4529 CallLoadIC(NOT_CONTEXTUAL); | 4529 CallLoadIC(NOT_CONTEXTUAL); |
4530 } | 4530 } |
4531 | 4531 |
4532 | 4532 |
4533 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 4533 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
4534 ZoneList<Expression*>* args = expr->arguments(); | 4534 ZoneList<Expression*>* args = expr->arguments(); |
4535 int arg_count = args->length(); | 4535 int arg_count = args->length(); |
4536 | 4536 |
4537 // Record source position of the IC call. | 4537 // Record source position of the IC call. |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4958 | 4958 |
4959 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { | 4959 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { |
4960 VariableProxy* proxy = expr->AsVariableProxy(); | 4960 VariableProxy* proxy = expr->AsVariableProxy(); |
4961 DCHECK(!context()->IsEffect()); | 4961 DCHECK(!context()->IsEffect()); |
4962 DCHECK(!context()->IsTest()); | 4962 DCHECK(!context()->IsTest()); |
4963 | 4963 |
4964 if (proxy != NULL && proxy->var()->IsUnallocated()) { | 4964 if (proxy != NULL && proxy->var()->IsUnallocated()) { |
4965 Comment cmnt(masm_, "[ Global variable"); | 4965 Comment cmnt(masm_, "[ Global variable"); |
4966 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 4966 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
4967 __ mov(LoadDescriptor::NameRegister(), Immediate(proxy->name())); | 4967 __ mov(LoadDescriptor::NameRegister(), Immediate(proxy->name())); |
4968 __ mov(VectorLoadICDescriptor::SlotRegister(), | 4968 __ mov(LoadDescriptor::SlotRegister(), |
4969 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); | 4969 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
4970 // Use a regular load, not a contextual load, to avoid a reference | 4970 // Use a regular load, not a contextual load, to avoid a reference |
4971 // error. | 4971 // error. |
4972 CallLoadIC(NOT_CONTEXTUAL); | 4972 CallLoadIC(NOT_CONTEXTUAL); |
4973 PrepareForBailout(expr, TOS_REG); | 4973 PrepareForBailout(expr, TOS_REG); |
4974 context()->Plug(eax); | 4974 context()->Plug(eax); |
4975 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { | 4975 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { |
4976 Comment cmnt(masm_, "[ Lookup slot"); | 4976 Comment cmnt(masm_, "[ Lookup slot"); |
4977 Label done, slow; | 4977 Label done, slow; |
4978 | 4978 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5339 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5339 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5340 Assembler::target_address_at(call_target_address, | 5340 Assembler::target_address_at(call_target_address, |
5341 unoptimized_code)); | 5341 unoptimized_code)); |
5342 return OSR_AFTER_STACK_CHECK; | 5342 return OSR_AFTER_STACK_CHECK; |
5343 } | 5343 } |
5344 | 5344 |
5345 | 5345 |
5346 } } // namespace v8::internal | 5346 } } // namespace v8::internal |
5347 | 5347 |
5348 #endif // V8_TARGET_ARCH_X87 | 5348 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |