| 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 Handle<JSObject> holder_obj, | 386 Handle<JSObject> holder_obj, |
| 387 IC::UtilityId id) { | 387 IC::UtilityId id) { |
| 388 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); | 388 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); |
| 389 __ CallExternalReference( | 389 __ CallExternalReference( |
| 390 ExternalReference(IC_Utility(id), masm->isolate()), | 390 ExternalReference(IC_Utility(id), masm->isolate()), |
| 391 StubCache::kInterceptorArgsLength); | 391 StubCache::kInterceptorArgsLength); |
| 392 } | 392 } |
| 393 | 393 |
| 394 | 394 |
| 395 // Generate call to api function. | 395 // Generate call to api function. |
| 396 void StubCompiler::GenerateFastApiCall(MacroAssembler* masm, | 396 static void GenerateFastApiCall(MacroAssembler* masm, |
| 397 const CallOptimization& optimization, | 397 const CallOptimization& optimization, |
| 398 Handle<Map> receiver_map, | 398 Handle<Map> receiver_map, |
| 399 Register receiver, | 399 Register receiver, |
| 400 Register scratch_in, | 400 Register scratch_in, |
| 401 bool is_store, | 401 int argc, |
| 402 int argc, | 402 Register* values) { |
| 403 Register* values) { | |
| 404 ASSERT(optimization.is_simple_api_call()); | 403 ASSERT(optimization.is_simple_api_call()); |
| 405 | 404 |
| 406 __ PopReturnAddressTo(scratch_in); | 405 __ PopReturnAddressTo(scratch_in); |
| 407 // receiver | 406 // receiver |
| 408 __ push(receiver); | 407 __ push(receiver); |
| 409 // Write the arguments to stack frame. | 408 // Write the arguments to stack frame. |
| 410 for (int i = 0; i < argc; i++) { | 409 for (int i = 0; i < argc; i++) { |
| 411 Register arg = values[argc-1-i]; | 410 Register arg = values[argc-1-i]; |
| 412 ASSERT(!receiver.is(arg)); | 411 ASSERT(!receiver.is(arg)); |
| 413 ASSERT(!scratch_in.is(arg)); | 412 ASSERT(!scratch_in.is(arg)); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 } else { | 458 } else { |
| 460 __ Move(call_data, call_data_obj); | 459 __ Move(call_data, call_data_obj); |
| 461 } | 460 } |
| 462 | 461 |
| 463 // Put api_function_address in place. | 462 // Put api_function_address in place. |
| 464 Address function_address = v8::ToCData<Address>(api_call_info->callback()); | 463 Address function_address = v8::ToCData<Address>(api_call_info->callback()); |
| 465 __ Move( | 464 __ Move( |
| 466 api_function_address, function_address, RelocInfo::EXTERNAL_REFERENCE); | 465 api_function_address, function_address, RelocInfo::EXTERNAL_REFERENCE); |
| 467 | 466 |
| 468 // Jump to stub. | 467 // Jump to stub. |
| 469 CallApiFunctionStub stub(is_store, call_data_undefined, argc); | 468 CallApiFunctionStub stub(true, call_data_undefined, argc); |
| 470 __ TailCallStub(&stub); | 469 __ TailCallStub(&stub); |
| 471 } | 470 } |
| 472 | 471 |
| 473 | 472 |
| 474 void StoreStubCompiler::GenerateRestoreName(MacroAssembler* masm, | 473 void StoreStubCompiler::GenerateRestoreName(MacroAssembler* masm, |
| 475 Label* label, | 474 Label* label, |
| 476 Handle<Name> name) { | 475 Handle<Name> name) { |
| 477 if (!label->is_unused()) { | 476 if (!label->is_unused()) { |
| 478 __ bind(label); | 477 __ bind(label); |
| 479 __ Move(this->name(), name); | 478 __ Move(this->name(), name); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 Register StubCompiler::CheckPrototypes(Handle<HeapType> type, | 766 Register StubCompiler::CheckPrototypes(Handle<HeapType> type, |
| 768 Register object_reg, | 767 Register object_reg, |
| 769 Handle<JSObject> holder, | 768 Handle<JSObject> holder, |
| 770 Register holder_reg, | 769 Register holder_reg, |
| 771 Register scratch1, | 770 Register scratch1, |
| 772 Register scratch2, | 771 Register scratch2, |
| 773 Handle<Name> name, | 772 Handle<Name> name, |
| 774 Label* miss, | 773 Label* miss, |
| 775 PrototypeCheckType check) { | 774 PrototypeCheckType check) { |
| 776 Handle<Map> receiver_map(IC::TypeToMap(*type, isolate())); | 775 Handle<Map> receiver_map(IC::TypeToMap(*type, isolate())); |
| 776 // Make sure that the type feedback oracle harvests the receiver map. |
| 777 // TODO(svenpanne) Remove this hack when all ICs are reworked. |
| 778 __ Move(scratch1, receiver_map); |
| 777 | 779 |
| 778 // Make sure there's no overlap between holder and object registers. | 780 // Make sure there's no overlap between holder and object registers. |
| 779 ASSERT(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); | 781 ASSERT(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); |
| 780 ASSERT(!scratch2.is(object_reg) && !scratch2.is(holder_reg) | 782 ASSERT(!scratch2.is(object_reg) && !scratch2.is(holder_reg) |
| 781 && !scratch2.is(scratch1)); | 783 && !scratch2.is(scratch1)); |
| 782 | 784 |
| 783 // Keep track of the current object in register reg. On the first | 785 // Keep track of the current object in register reg. On the first |
| 784 // iteration, reg is an alias for object_reg, on later iterations, | 786 // iteration, reg is an alias for object_reg, on later iterations, |
| 785 // it is an alias for holder_reg. | 787 // it is an alias for holder_reg. |
| 786 Register reg = object_reg; | 788 Register reg = object_reg; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 } else { | 963 } else { |
| 962 KeyedLoadFieldStub stub(field.is_inobject(holder), | 964 KeyedLoadFieldStub stub(field.is_inobject(holder), |
| 963 field.translate(holder), | 965 field.translate(holder), |
| 964 representation); | 966 representation); |
| 965 GenerateTailCall(masm(), stub.GetCode(isolate())); | 967 GenerateTailCall(masm(), stub.GetCode(isolate())); |
| 966 } | 968 } |
| 967 } | 969 } |
| 968 | 970 |
| 969 | 971 |
| 970 void LoadStubCompiler::GenerateLoadCallback( | 972 void LoadStubCompiler::GenerateLoadCallback( |
| 973 const CallOptimization& call_optimization, |
| 974 Handle<Map> receiver_map) { |
| 975 GenerateFastApiCall( |
| 976 masm(), call_optimization, receiver_map, |
| 977 receiver(), scratch1(), 0, NULL); |
| 978 } |
| 979 |
| 980 |
| 981 void LoadStubCompiler::GenerateLoadCallback( |
| 971 Register reg, | 982 Register reg, |
| 972 Handle<ExecutableAccessorInfo> callback) { | 983 Handle<ExecutableAccessorInfo> callback) { |
| 973 // Insert additional parameters into the stack frame above return address. | 984 // Insert additional parameters into the stack frame above return address. |
| 974 ASSERT(!scratch4().is(reg)); | 985 ASSERT(!scratch4().is(reg)); |
| 975 __ PopReturnAddressTo(scratch4()); | 986 __ PopReturnAddressTo(scratch4()); |
| 976 | 987 |
| 977 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0); | 988 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0); |
| 978 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1); | 989 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1); |
| 979 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2); | 990 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2); |
| 980 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3); | 991 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1140 // Do tail-call to the runtime system. | 1151 // Do tail-call to the runtime system. |
| 1141 ExternalReference store_callback_property = | 1152 ExternalReference store_callback_property = |
| 1142 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate()); | 1153 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate()); |
| 1143 __ TailCallExternalReference(store_callback_property, 5, 1); | 1154 __ TailCallExternalReference(store_callback_property, 5, 1); |
| 1144 | 1155 |
| 1145 // Return the generated code. | 1156 // Return the generated code. |
| 1146 return GetCode(kind(), Code::FAST, name); | 1157 return GetCode(kind(), Code::FAST, name); |
| 1147 } | 1158 } |
| 1148 | 1159 |
| 1149 | 1160 |
| 1161 Handle<Code> StoreStubCompiler::CompileStoreCallback( |
| 1162 Handle<JSObject> object, |
| 1163 Handle<JSObject> holder, |
| 1164 Handle<Name> name, |
| 1165 const CallOptimization& call_optimization) { |
| 1166 HandlerFrontend(IC::CurrentTypeOf(object, isolate()), |
| 1167 receiver(), holder, name); |
| 1168 |
| 1169 Register values[] = { value() }; |
| 1170 GenerateFastApiCall( |
| 1171 masm(), call_optimization, handle(object->map()), |
| 1172 receiver(), scratch1(), 1, values); |
| 1173 |
| 1174 // Return the generated code. |
| 1175 return GetCode(kind(), Code::FAST, name); |
| 1176 } |
| 1177 |
| 1178 |
| 1150 #undef __ | 1179 #undef __ |
| 1151 #define __ ACCESS_MASM(masm) | 1180 #define __ ACCESS_MASM(masm) |
| 1152 | 1181 |
| 1153 | 1182 |
| 1154 void StoreStubCompiler::GenerateStoreViaSetter( | 1183 void StoreStubCompiler::GenerateStoreViaSetter( |
| 1155 MacroAssembler* masm, | 1184 MacroAssembler* masm, |
| 1156 Handle<HeapType> type, | 1185 Handle<HeapType> type, |
| 1157 Handle<JSFunction> setter) { | 1186 Handle<JSFunction> setter) { |
| 1158 // ----------- S t a t e ------------- | 1187 // ----------- S t a t e ------------- |
| 1159 // -- rax : value | 1188 // -- rax : value |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 // ----------------------------------- | 1502 // ----------------------------------- |
| 1474 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 1503 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
| 1475 } | 1504 } |
| 1476 | 1505 |
| 1477 | 1506 |
| 1478 #undef __ | 1507 #undef __ |
| 1479 | 1508 |
| 1480 } } // namespace v8::internal | 1509 } } // namespace v8::internal |
| 1481 | 1510 |
| 1482 #endif // V8_TARGET_ARCH_X64 | 1511 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |