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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 Register name, | 411 Register name, |
412 Handle<JSObject> holder_obj, | 412 Handle<JSObject> holder_obj, |
413 IC::UtilityId id) { | 413 IC::UtilityId id) { |
414 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); | 414 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); |
415 __ CallExternalReference( | 415 __ CallExternalReference( |
416 ExternalReference(IC_Utility(id), masm->isolate()), | 416 ExternalReference(IC_Utility(id), masm->isolate()), |
417 StubCache::kInterceptorArgsLength); | 417 StubCache::kInterceptorArgsLength); |
418 } | 418 } |
419 | 419 |
420 | 420 |
421 static void GenerateFastApiCallBody(MacroAssembler* masm, | 421 // Generate call to api function. |
422 const CallOptimization& optimization, | 422 // This function uses push() to generate smaller, faster code than |
423 int argc, | 423 // the version above. It is an optimization that should will be removed |
424 Register holder_in, | 424 // when api call ICs are generated in hydrogen. |
425 bool restore_context) { | 425 static void GenerateFastApiCall(MacroAssembler* masm, |
| 426 const CallOptimization& optimization, |
| 427 Handle<Map> receiver_map, |
| 428 Register receiver, |
| 429 Register scratch_in, |
| 430 int argc, |
| 431 Register* values) { |
| 432 // Copy return value. |
| 433 __ pop(scratch_in); |
| 434 // receiver |
| 435 __ push(receiver); |
| 436 // Write the arguments to stack frame. |
| 437 for (int i = 0; i < argc; i++) { |
| 438 Register arg = values[argc-1-i]; |
| 439 ASSERT(!receiver.is(arg)); |
| 440 ASSERT(!scratch_in.is(arg)); |
| 441 __ push(arg); |
| 442 } |
| 443 __ push(scratch_in); |
| 444 // Stack now matches JSFunction abi. |
426 ASSERT(optimization.is_simple_api_call()); | 445 ASSERT(optimization.is_simple_api_call()); |
427 | 446 |
428 // Abi for CallApiFunctionStub. | 447 // Abi for CallApiFunctionStub. |
429 Register callee = eax; | 448 Register callee = eax; |
430 Register call_data = ebx; | 449 Register call_data = ebx; |
431 Register holder = ecx; | 450 Register holder = ecx; |
432 Register api_function_address = edx; | 451 Register api_function_address = edx; |
| 452 Register scratch = edi; // scratch_in is no longer valid. |
433 | 453 |
434 // Put holder in place. | 454 // Put holder in place. |
435 __ Move(holder, holder_in); | 455 CallOptimization::HolderLookup holder_lookup; |
436 | 456 Handle<JSObject> api_holder = optimization.LookupHolderOfExpectedType( |
437 Register scratch = edi; | 457 receiver_map, |
| 458 &holder_lookup); |
| 459 switch (holder_lookup) { |
| 460 case CallOptimization::kHolderIsReceiver: |
| 461 __ Move(holder, receiver); |
| 462 break; |
| 463 case CallOptimization::kHolderFound: |
| 464 __ LoadHeapObject(holder, api_holder); |
| 465 break; |
| 466 case CallOptimization::kHolderNotFound: |
| 467 UNREACHABLE(); |
| 468 break; |
| 469 } |
438 | 470 |
439 Isolate* isolate = masm->isolate(); | 471 Isolate* isolate = masm->isolate(); |
440 Handle<JSFunction> function = optimization.constant_function(); | 472 Handle<JSFunction> function = optimization.constant_function(); |
441 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); | 473 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); |
442 Handle<Object> call_data_obj(api_call_info->data(), isolate); | 474 Handle<Object> call_data_obj(api_call_info->data(), isolate); |
443 | 475 |
444 // Put callee in place. | 476 // Put callee in place. |
445 __ LoadHeapObject(callee, function); | 477 __ LoadHeapObject(callee, function); |
446 | 478 |
447 bool call_data_undefined = false; | 479 bool call_data_undefined = false; |
448 // Put call_data in place. | 480 // Put call_data in place. |
449 if (isolate->heap()->InNewSpace(*call_data_obj)) { | 481 if (isolate->heap()->InNewSpace(*call_data_obj)) { |
450 __ mov(scratch, api_call_info); | 482 __ mov(scratch, api_call_info); |
451 __ mov(call_data, FieldOperand(scratch, CallHandlerInfo::kDataOffset)); | 483 __ mov(call_data, FieldOperand(scratch, CallHandlerInfo::kDataOffset)); |
452 } else if (call_data_obj->IsUndefined()) { | 484 } else if (call_data_obj->IsUndefined()) { |
453 call_data_undefined = true; | 485 call_data_undefined = true; |
454 __ mov(call_data, Immediate(isolate->factory()->undefined_value())); | 486 __ mov(call_data, Immediate(isolate->factory()->undefined_value())); |
455 } else { | 487 } else { |
456 __ mov(call_data, call_data_obj); | 488 __ mov(call_data, call_data_obj); |
457 } | 489 } |
458 | 490 |
459 // Put api_function_address in place. | 491 // Put api_function_address in place. |
460 Address function_address = v8::ToCData<Address>(api_call_info->callback()); | 492 Address function_address = v8::ToCData<Address>(api_call_info->callback()); |
461 __ mov(api_function_address, Immediate(function_address)); | 493 __ mov(api_function_address, Immediate(function_address)); |
462 | 494 |
463 // Jump to stub. | 495 // Jump to stub. |
464 CallApiFunctionStub stub(restore_context, call_data_undefined, argc); | 496 CallApiFunctionStub stub(true, call_data_undefined, argc); |
465 __ TailCallStub(&stub); | 497 __ TailCallStub(&stub); |
466 } | 498 } |
467 | 499 |
468 | 500 |
469 // Generate call to api function. | |
470 // This function uses push() to generate smaller, faster code than | |
471 // the version above. It is an optimization that should will be removed | |
472 // when api call ICs are generated in hydrogen. | |
473 static void GenerateFastApiCall(MacroAssembler* masm, | |
474 const CallOptimization& optimization, | |
475 Register receiver, | |
476 Register scratch1, | |
477 int argc, | |
478 Register* values) { | |
479 // Copy return value. | |
480 __ pop(scratch1); | |
481 // receiver | |
482 __ push(receiver); | |
483 // Write the arguments to stack frame. | |
484 for (int i = 0; i < argc; i++) { | |
485 Register arg = values[argc-1-i]; | |
486 ASSERT(!receiver.is(arg)); | |
487 ASSERT(!scratch1.is(arg)); | |
488 __ push(arg); | |
489 } | |
490 __ push(scratch1); | |
491 // Stack now matches JSFunction abi. | |
492 GenerateFastApiCallBody(masm, | |
493 optimization, | |
494 argc, | |
495 receiver, | |
496 true); | |
497 } | |
498 | |
499 | |
500 void StoreStubCompiler::GenerateRestoreName(MacroAssembler* masm, | 501 void StoreStubCompiler::GenerateRestoreName(MacroAssembler* masm, |
501 Label* label, | 502 Label* label, |
502 Handle<Name> name) { | 503 Handle<Name> name) { |
503 if (!label->is_unused()) { | 504 if (!label->is_unused()) { |
504 __ bind(label); | 505 __ bind(label); |
505 __ mov(this->name(), Immediate(name)); | 506 __ mov(this->name(), Immediate(name)); |
506 } | 507 } |
507 } | 508 } |
508 | 509 |
509 | 510 |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 } else { | 1059 } else { |
1059 KeyedLoadFieldStub stub(field.is_inobject(holder), | 1060 KeyedLoadFieldStub stub(field.is_inobject(holder), |
1060 field.translate(holder), | 1061 field.translate(holder), |
1061 representation); | 1062 representation); |
1062 GenerateTailCall(masm(), stub.GetCode(isolate())); | 1063 GenerateTailCall(masm(), stub.GetCode(isolate())); |
1063 } | 1064 } |
1064 } | 1065 } |
1065 | 1066 |
1066 | 1067 |
1067 void LoadStubCompiler::GenerateLoadCallback( | 1068 void LoadStubCompiler::GenerateLoadCallback( |
1068 const CallOptimization& call_optimization) { | 1069 const CallOptimization& call_optimization, |
| 1070 Handle<Map> receiver_map) { |
1069 GenerateFastApiCall( | 1071 GenerateFastApiCall( |
1070 masm(), call_optimization, receiver(), | 1072 masm(), call_optimization, receiver_map, |
1071 scratch1(), 0, NULL); | 1073 receiver(), scratch1(), 0, NULL); |
1072 } | 1074 } |
1073 | 1075 |
1074 | 1076 |
1075 void LoadStubCompiler::GenerateLoadCallback( | 1077 void LoadStubCompiler::GenerateLoadCallback( |
1076 Register reg, | 1078 Register reg, |
1077 Handle<ExecutableAccessorInfo> callback) { | 1079 Handle<ExecutableAccessorInfo> callback) { |
1078 // Insert additional parameters into the stack frame above return address. | 1080 // Insert additional parameters into the stack frame above return address. |
1079 ASSERT(!scratch3().is(reg)); | 1081 ASSERT(!scratch3().is(reg)); |
1080 __ pop(scratch3()); // Get return address to place it below. | 1082 __ pop(scratch3()); // Get return address to place it below. |
1081 | 1083 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 Handle<Code> StoreStubCompiler::CompileStoreCallback( | 1266 Handle<Code> StoreStubCompiler::CompileStoreCallback( |
1265 Handle<JSObject> object, | 1267 Handle<JSObject> object, |
1266 Handle<JSObject> holder, | 1268 Handle<JSObject> holder, |
1267 Handle<Name> name, | 1269 Handle<Name> name, |
1268 const CallOptimization& call_optimization) { | 1270 const CallOptimization& call_optimization) { |
1269 HandlerFrontend(IC::CurrentTypeOf(object, isolate()), | 1271 HandlerFrontend(IC::CurrentTypeOf(object, isolate()), |
1270 receiver(), holder, name); | 1272 receiver(), holder, name); |
1271 | 1273 |
1272 Register values[] = { value() }; | 1274 Register values[] = { value() }; |
1273 GenerateFastApiCall( | 1275 GenerateFastApiCall( |
1274 masm(), call_optimization, receiver(), | 1276 masm(), call_optimization, handle(object->map()), |
1275 scratch1(), 1, values); | 1277 receiver(), scratch1(), 1, values); |
1276 | 1278 |
1277 // Return the generated code. | 1279 // Return the generated code. |
1278 return GetCode(kind(), Code::FAST, name); | 1280 return GetCode(kind(), Code::FAST, name); |
1279 } | 1281 } |
1280 | 1282 |
1281 | 1283 |
1282 #undef __ | 1284 #undef __ |
1283 #define __ ACCESS_MASM(masm) | 1285 #define __ ACCESS_MASM(masm) |
1284 | 1286 |
1285 | 1287 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1581 // ----------------------------------- | 1583 // ----------------------------------- |
1582 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 1584 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
1583 } | 1585 } |
1584 | 1586 |
1585 | 1587 |
1586 #undef __ | 1588 #undef __ |
1587 | 1589 |
1588 } } // namespace v8::internal | 1590 } } // namespace v8::internal |
1589 | 1591 |
1590 #endif // V8_TARGET_ARCH_IA32 | 1592 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |