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_X64 | 7 #if V8_TARGET_ARCH_X64 |
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 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 | 1286 |
1287 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { | 1287 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { |
1288 Comment cnmt(masm_, "[ SuperReference "); | 1288 Comment cnmt(masm_, "[ SuperReference "); |
1289 | 1289 |
1290 __ movp(LoadDescriptor::ReceiverRegister(), | 1290 __ movp(LoadDescriptor::ReceiverRegister(), |
1291 Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 1291 Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
1292 | 1292 |
1293 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol()); | 1293 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol()); |
1294 __ Move(LoadDescriptor::NameRegister(), home_object_symbol); | 1294 __ Move(LoadDescriptor::NameRegister(), home_object_symbol); |
1295 | 1295 |
1296 if (FLAG_vector_ics) { | 1296 __ Move(VectorLoadICDescriptor::SlotRegister(), |
1297 __ Move(VectorLoadICDescriptor::SlotRegister(), | 1297 SmiFromSlot(expr->HomeObjectFeedbackSlot())); |
1298 SmiFromSlot(expr->HomeObjectFeedbackSlot())); | 1298 CallLoadIC(NOT_CONTEXTUAL); |
1299 CallLoadIC(NOT_CONTEXTUAL); | |
1300 } else { | |
1301 CallLoadIC(NOT_CONTEXTUAL, expr->HomeObjectFeedbackId()); | |
1302 } | |
1303 | |
1304 | 1299 |
1305 __ Cmp(rax, isolate()->factory()->undefined_value()); | 1300 __ Cmp(rax, isolate()->factory()->undefined_value()); |
1306 Label done; | 1301 Label done; |
1307 __ j(not_equal, &done); | 1302 __ j(not_equal, &done); |
1308 __ CallRuntime(Runtime::kThrowNonMethodError, 0); | 1303 __ CallRuntime(Runtime::kThrowNonMethodError, 0); |
1309 __ bind(&done); | 1304 __ bind(&done); |
1310 } | 1305 } |
1311 | 1306 |
1312 | 1307 |
1313 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, | 1308 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 // Load next context in chain. | 1364 // Load next context in chain. |
1370 __ movp(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); | 1365 __ movp(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); |
1371 __ jmp(&next); | 1366 __ jmp(&next); |
1372 __ bind(&fast); | 1367 __ bind(&fast); |
1373 } | 1368 } |
1374 | 1369 |
1375 // All extension objects were empty and it is safe to use a global | 1370 // All extension objects were empty and it is safe to use a global |
1376 // load IC call. | 1371 // load IC call. |
1377 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1372 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1378 __ Move(LoadDescriptor::NameRegister(), proxy->var()->name()); | 1373 __ Move(LoadDescriptor::NameRegister(), proxy->var()->name()); |
1379 if (FLAG_vector_ics) { | 1374 __ Move(VectorLoadICDescriptor::SlotRegister(), |
1380 __ Move(VectorLoadICDescriptor::SlotRegister(), | 1375 SmiFromSlot(proxy->VariableFeedbackSlot())); |
1381 SmiFromSlot(proxy->VariableFeedbackSlot())); | |
1382 } | |
1383 | 1376 |
1384 ContextualMode mode = (typeof_state == INSIDE_TYPEOF) | 1377 ContextualMode mode = (typeof_state == INSIDE_TYPEOF) |
1385 ? NOT_CONTEXTUAL | 1378 ? NOT_CONTEXTUAL |
1386 : CONTEXTUAL; | 1379 : CONTEXTUAL; |
1387 CallLoadIC(mode); | 1380 CallLoadIC(mode); |
1388 } | 1381 } |
1389 | 1382 |
1390 | 1383 |
1391 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, | 1384 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, |
1392 Label* slow) { | 1385 Label* slow) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); | 1449 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); |
1457 Variable* var = proxy->var(); | 1450 Variable* var = proxy->var(); |
1458 | 1451 |
1459 // Three cases: global variables, lookup variables, and all other types of | 1452 // Three cases: global variables, lookup variables, and all other types of |
1460 // variables. | 1453 // variables. |
1461 switch (var->location()) { | 1454 switch (var->location()) { |
1462 case Variable::UNALLOCATED: { | 1455 case Variable::UNALLOCATED: { |
1463 Comment cmnt(masm_, "[ Global variable"); | 1456 Comment cmnt(masm_, "[ Global variable"); |
1464 __ Move(LoadDescriptor::NameRegister(), var->name()); | 1457 __ Move(LoadDescriptor::NameRegister(), var->name()); |
1465 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1458 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1466 if (FLAG_vector_ics) { | 1459 __ Move(VectorLoadICDescriptor::SlotRegister(), |
1467 __ Move(VectorLoadICDescriptor::SlotRegister(), | 1460 SmiFromSlot(proxy->VariableFeedbackSlot())); |
1468 SmiFromSlot(proxy->VariableFeedbackSlot())); | |
1469 } | |
1470 CallGlobalLoadIC(var->name()); | 1461 CallGlobalLoadIC(var->name()); |
1471 context()->Plug(rax); | 1462 context()->Plug(rax); |
1472 break; | 1463 break; |
1473 } | 1464 } |
1474 | 1465 |
1475 case Variable::PARAMETER: | 1466 case Variable::PARAMETER: |
1476 case Variable::LOCAL: | 1467 case Variable::LOCAL: |
1477 case Variable::CONTEXT: { | 1468 case Variable::CONTEXT: { |
1478 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context slot" | 1469 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context slot" |
1479 : "[ Stack slot"); | 1470 : "[ Stack slot"); |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2151 __ bind(&l_next); | 2142 __ bind(&l_next); |
2152 | 2143 |
2153 __ LoadRoot(load_name, Heap::knext_stringRootIndex); | 2144 __ LoadRoot(load_name, Heap::knext_stringRootIndex); |
2154 __ Push(load_name); // "next" | 2145 __ Push(load_name); // "next" |
2155 __ Push(Operand(rsp, 2 * kPointerSize)); // iter | 2146 __ Push(Operand(rsp, 2 * kPointerSize)); // iter |
2156 __ Push(rax); // received | 2147 __ Push(rax); // received |
2157 | 2148 |
2158 // result = receiver[f](arg); | 2149 // result = receiver[f](arg); |
2159 __ bind(&l_call); | 2150 __ bind(&l_call); |
2160 __ movp(load_receiver, Operand(rsp, kPointerSize)); | 2151 __ movp(load_receiver, Operand(rsp, kPointerSize)); |
2161 if (FLAG_vector_ics) { | 2152 __ Move(VectorLoadICDescriptor::SlotRegister(), |
2162 __ Move(VectorLoadICDescriptor::SlotRegister(), | 2153 SmiFromSlot(expr->KeyedLoadFeedbackSlot())); |
2163 SmiFromSlot(expr->KeyedLoadFeedbackSlot())); | |
2164 } | |
2165 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 2154 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2166 CallIC(ic, TypeFeedbackId::None()); | 2155 CallIC(ic, TypeFeedbackId::None()); |
2167 __ movp(rdi, rax); | 2156 __ movp(rdi, rax); |
2168 __ movp(Operand(rsp, 2 * kPointerSize), rdi); | 2157 __ movp(Operand(rsp, 2 * kPointerSize), rdi); |
2169 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); | 2158 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); |
2170 __ CallStub(&stub); | 2159 __ CallStub(&stub); |
2171 | 2160 |
2172 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2161 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
2173 __ Drop(1); // The function is still on the stack; drop it. | 2162 __ Drop(1); // The function is still on the stack; drop it. |
2174 | 2163 |
2175 // if (!result.done) goto l_try; | 2164 // if (!result.done) goto l_try; |
2176 __ bind(&l_loop); | 2165 __ bind(&l_loop); |
2177 __ Move(load_receiver, rax); | 2166 __ Move(load_receiver, rax); |
2178 __ Push(load_receiver); // save result | 2167 __ Push(load_receiver); // save result |
2179 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" | 2168 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" |
2180 if (FLAG_vector_ics) { | 2169 __ Move(VectorLoadICDescriptor::SlotRegister(), |
2181 __ Move(VectorLoadICDescriptor::SlotRegister(), | 2170 SmiFromSlot(expr->DoneFeedbackSlot())); |
2182 SmiFromSlot(expr->DoneFeedbackSlot())); | |
2183 } | |
2184 CallLoadIC(NOT_CONTEXTUAL); // rax=result.done | 2171 CallLoadIC(NOT_CONTEXTUAL); // rax=result.done |
2185 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); | 2172 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); |
2186 CallIC(bool_ic); | 2173 CallIC(bool_ic); |
2187 __ testp(result_register(), result_register()); | 2174 __ testp(result_register(), result_register()); |
2188 __ j(zero, &l_try); | 2175 __ j(zero, &l_try); |
2189 | 2176 |
2190 // result.value | 2177 // result.value |
2191 __ Pop(load_receiver); // result | 2178 __ Pop(load_receiver); // result |
2192 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value" | 2179 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value" |
2193 if (FLAG_vector_ics) { | 2180 __ Move(VectorLoadICDescriptor::SlotRegister(), |
2194 __ Move(VectorLoadICDescriptor::SlotRegister(), | 2181 SmiFromSlot(expr->ValueFeedbackSlot())); |
2195 SmiFromSlot(expr->ValueFeedbackSlot())); | |
2196 } | |
2197 CallLoadIC(NOT_CONTEXTUAL); // result.value in rax | 2182 CallLoadIC(NOT_CONTEXTUAL); // result.value in rax |
2198 context()->DropAndPlug(2, rax); // drop iter and g | 2183 context()->DropAndPlug(2, rax); // drop iter and g |
2199 break; | 2184 break; |
2200 } | 2185 } |
2201 } | 2186 } |
2202 } | 2187 } |
2203 | 2188 |
2204 | 2189 |
2205 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 2190 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
2206 Expression *value, | 2191 Expression *value, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2325 rcx, rdx, kDontSaveFPRegs); | 2310 rcx, rdx, kDontSaveFPRegs); |
2326 } | 2311 } |
2327 | 2312 |
2328 | 2313 |
2329 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { | 2314 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
2330 SetSourcePosition(prop->position()); | 2315 SetSourcePosition(prop->position()); |
2331 Literal* key = prop->key()->AsLiteral(); | 2316 Literal* key = prop->key()->AsLiteral(); |
2332 DCHECK(!prop->IsSuperAccess()); | 2317 DCHECK(!prop->IsSuperAccess()); |
2333 | 2318 |
2334 __ Move(LoadDescriptor::NameRegister(), key->value()); | 2319 __ Move(LoadDescriptor::NameRegister(), key->value()); |
2335 if (FLAG_vector_ics) { | 2320 __ Move(VectorLoadICDescriptor::SlotRegister(), |
2336 __ Move(VectorLoadICDescriptor::SlotRegister(), | 2321 SmiFromSlot(prop->PropertyFeedbackSlot())); |
2337 SmiFromSlot(prop->PropertyFeedbackSlot())); | 2322 CallLoadIC(NOT_CONTEXTUAL); |
2338 CallLoadIC(NOT_CONTEXTUAL); | |
2339 } else { | |
2340 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); | |
2341 } | |
2342 } | 2323 } |
2343 | 2324 |
2344 | 2325 |
2345 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { | 2326 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { |
2346 // Stack: receiver, home_object | 2327 // Stack: receiver, home_object |
2347 SetSourcePosition(prop->position()); | 2328 SetSourcePosition(prop->position()); |
2348 Literal* key = prop->key()->AsLiteral(); | 2329 Literal* key = prop->key()->AsLiteral(); |
2349 DCHECK(!key->value()->IsSmi()); | 2330 DCHECK(!key->value()->IsSmi()); |
2350 DCHECK(prop->IsSuperAccess()); | 2331 DCHECK(prop->IsSuperAccess()); |
2351 | 2332 |
2352 __ Push(key->value()); | 2333 __ Push(key->value()); |
2353 __ CallRuntime(Runtime::kLoadFromSuper, 3); | 2334 __ CallRuntime(Runtime::kLoadFromSuper, 3); |
2354 } | 2335 } |
2355 | 2336 |
2356 | 2337 |
2357 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2338 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
2358 SetSourcePosition(prop->position()); | 2339 SetSourcePosition(prop->position()); |
2359 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 2340 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2360 if (FLAG_vector_ics) { | 2341 __ Move(VectorLoadICDescriptor::SlotRegister(), |
2361 __ Move(VectorLoadICDescriptor::SlotRegister(), | 2342 SmiFromSlot(prop->PropertyFeedbackSlot())); |
2362 SmiFromSlot(prop->PropertyFeedbackSlot())); | 2343 CallIC(ic); |
2363 CallIC(ic); | |
2364 } else { | |
2365 CallIC(ic, prop->PropertyFeedbackId()); | |
2366 } | |
2367 } | 2344 } |
2368 | 2345 |
2369 | 2346 |
2370 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { | 2347 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { |
2371 // Stack: receiver, home_object, key. | 2348 // Stack: receiver, home_object, key. |
2372 SetSourcePosition(prop->position()); | 2349 SetSourcePosition(prop->position()); |
2373 | 2350 |
2374 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); | 2351 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); |
2375 } | 2352 } |
2376 | 2353 |
(...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4568 | 4545 |
4569 | 4546 |
4570 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { | 4547 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
4571 // Push the builtins object as receiver. | 4548 // Push the builtins object as receiver. |
4572 __ movp(rax, GlobalObjectOperand()); | 4549 __ movp(rax, GlobalObjectOperand()); |
4573 __ Push(FieldOperand(rax, GlobalObject::kBuiltinsOffset)); | 4550 __ Push(FieldOperand(rax, GlobalObject::kBuiltinsOffset)); |
4574 | 4551 |
4575 // Load the function from the receiver. | 4552 // Load the function from the receiver. |
4576 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); | 4553 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
4577 __ Move(LoadDescriptor::NameRegister(), expr->name()); | 4554 __ Move(LoadDescriptor::NameRegister(), expr->name()); |
4578 if (FLAG_vector_ics) { | 4555 __ Move(VectorLoadICDescriptor::SlotRegister(), |
4579 __ Move(VectorLoadICDescriptor::SlotRegister(), | 4556 SmiFromSlot(expr->CallRuntimeFeedbackSlot())); |
4580 SmiFromSlot(expr->CallRuntimeFeedbackSlot())); | 4557 CallLoadIC(NOT_CONTEXTUAL); |
4581 CallLoadIC(NOT_CONTEXTUAL); | |
4582 } else { | |
4583 CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId()); | |
4584 } | |
4585 } | 4558 } |
4586 | 4559 |
4587 | 4560 |
4588 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 4561 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
4589 ZoneList<Expression*>* args = expr->arguments(); | 4562 ZoneList<Expression*>* args = expr->arguments(); |
4590 int arg_count = args->length(); | 4563 int arg_count = args->length(); |
4591 | 4564 |
4592 // Record source position of the IC call. | 4565 // Record source position of the IC call. |
4593 SetSourcePosition(expr->position()); | 4566 SetSourcePosition(expr->position()); |
4594 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 4567 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5009 | 4982 |
5010 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { | 4983 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { |
5011 VariableProxy* proxy = expr->AsVariableProxy(); | 4984 VariableProxy* proxy = expr->AsVariableProxy(); |
5012 DCHECK(!context()->IsEffect()); | 4985 DCHECK(!context()->IsEffect()); |
5013 DCHECK(!context()->IsTest()); | 4986 DCHECK(!context()->IsTest()); |
5014 | 4987 |
5015 if (proxy != NULL && proxy->var()->IsUnallocated()) { | 4988 if (proxy != NULL && proxy->var()->IsUnallocated()) { |
5016 Comment cmnt(masm_, "[ Global variable"); | 4989 Comment cmnt(masm_, "[ Global variable"); |
5017 __ Move(LoadDescriptor::NameRegister(), proxy->name()); | 4990 __ Move(LoadDescriptor::NameRegister(), proxy->name()); |
5018 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 4991 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
5019 if (FLAG_vector_ics) { | 4992 __ Move(VectorLoadICDescriptor::SlotRegister(), |
5020 __ Move(VectorLoadICDescriptor::SlotRegister(), | 4993 SmiFromSlot(proxy->VariableFeedbackSlot())); |
5021 SmiFromSlot(proxy->VariableFeedbackSlot())); | |
5022 } | |
5023 // Use a regular load, not a contextual load, to avoid a reference | 4994 // Use a regular load, not a contextual load, to avoid a reference |
5024 // error. | 4995 // error. |
5025 CallLoadIC(NOT_CONTEXTUAL); | 4996 CallLoadIC(NOT_CONTEXTUAL); |
5026 PrepareForBailout(expr, TOS_REG); | 4997 PrepareForBailout(expr, TOS_REG); |
5027 context()->Plug(rax); | 4998 context()->Plug(rax); |
5028 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { | 4999 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { |
5029 Comment cmnt(masm_, "[ Lookup slot"); | 5000 Comment cmnt(masm_, "[ Lookup slot"); |
5030 Label done, slow; | 5001 Label done, slow; |
5031 | 5002 |
5032 // Generate code for loading from variables potentially shadowed | 5003 // Generate code for loading from variables potentially shadowed |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5394 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5365 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5395 Assembler::target_address_at(call_target_address, | 5366 Assembler::target_address_at(call_target_address, |
5396 unoptimized_code)); | 5367 unoptimized_code)); |
5397 return OSR_AFTER_STACK_CHECK; | 5368 return OSR_AFTER_STACK_CHECK; |
5398 } | 5369 } |
5399 | 5370 |
5400 | 5371 |
5401 } } // namespace v8::internal | 5372 } } // namespace v8::internal |
5402 | 5373 |
5403 #endif // V8_TARGET_ARCH_X64 | 5374 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |