| 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // Generate call to api function. | 421 // Generate call to api function. |
| 422 // This function uses push() to generate smaller, faster code than | 422 // This function uses push() to generate smaller, faster code than |
| 423 // the version above. It is an optimization that should will be removed | 423 // the version above. It is an optimization that should will be removed |
| 424 // when api call ICs are generated in hydrogen. | 424 // when api call ICs are generated in hydrogen. |
| 425 void StubCompiler::GenerateFastApiCall(MacroAssembler* masm, | 425 static void GenerateFastApiCall(MacroAssembler* masm, |
| 426 const CallOptimization& optimization, | 426 const CallOptimization& optimization, |
| 427 Handle<Map> receiver_map, | 427 Handle<Map> receiver_map, |
| 428 Register receiver, | 428 Register receiver, |
| 429 Register scratch_in, | 429 Register scratch_in, |
| 430 bool is_store, | 430 int argc, |
| 431 int argc, | 431 Register* values) { |
| 432 Register* values) { | |
| 433 // Copy return value. | 432 // Copy return value. |
| 434 __ pop(scratch_in); | 433 __ pop(scratch_in); |
| 435 // receiver | 434 // receiver |
| 436 __ push(receiver); | 435 __ push(receiver); |
| 437 // Write the arguments to stack frame. | 436 // Write the arguments to stack frame. |
| 438 for (int i = 0; i < argc; i++) { | 437 for (int i = 0; i < argc; i++) { |
| 439 Register arg = values[argc-1-i]; | 438 Register arg = values[argc-1-i]; |
| 440 ASSERT(!receiver.is(arg)); | 439 ASSERT(!receiver.is(arg)); |
| 441 ASSERT(!scratch_in.is(arg)); | 440 ASSERT(!scratch_in.is(arg)); |
| 442 __ push(arg); | 441 __ push(arg); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 __ mov(call_data, Immediate(isolate->factory()->undefined_value())); | 486 __ mov(call_data, Immediate(isolate->factory()->undefined_value())); |
| 488 } else { | 487 } else { |
| 489 __ mov(call_data, call_data_obj); | 488 __ mov(call_data, call_data_obj); |
| 490 } | 489 } |
| 491 | 490 |
| 492 // Put api_function_address in place. | 491 // Put api_function_address in place. |
| 493 Address function_address = v8::ToCData<Address>(api_call_info->callback()); | 492 Address function_address = v8::ToCData<Address>(api_call_info->callback()); |
| 494 __ mov(api_function_address, Immediate(function_address)); | 493 __ mov(api_function_address, Immediate(function_address)); |
| 495 | 494 |
| 496 // Jump to stub. | 495 // Jump to stub. |
| 497 CallApiFunctionStub stub(is_store, call_data_undefined, argc); | 496 CallApiFunctionStub stub(true, call_data_undefined, argc); |
| 498 __ TailCallStub(&stub); | 497 __ TailCallStub(&stub); |
| 499 } | 498 } |
| 500 | 499 |
| 501 | 500 |
| 502 void StoreStubCompiler::GenerateRestoreName(MacroAssembler* masm, | 501 void StoreStubCompiler::GenerateRestoreName(MacroAssembler* masm, |
| 503 Label* label, | 502 Label* label, |
| 504 Handle<Name> name) { | 503 Handle<Name> name) { |
| 505 if (!label->is_unused()) { | 504 if (!label->is_unused()) { |
| 506 __ bind(label); | 505 __ bind(label); |
| 507 __ mov(this->name(), Immediate(name)); | 506 __ mov(this->name(), Immediate(name)); |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 Register StubCompiler::CheckPrototypes(Handle<HeapType> type, | 853 Register StubCompiler::CheckPrototypes(Handle<HeapType> type, |
| 855 Register object_reg, | 854 Register object_reg, |
| 856 Handle<JSObject> holder, | 855 Handle<JSObject> holder, |
| 857 Register holder_reg, | 856 Register holder_reg, |
| 858 Register scratch1, | 857 Register scratch1, |
| 859 Register scratch2, | 858 Register scratch2, |
| 860 Handle<Name> name, | 859 Handle<Name> name, |
| 861 Label* miss, | 860 Label* miss, |
| 862 PrototypeCheckType check) { | 861 PrototypeCheckType check) { |
| 863 Handle<Map> receiver_map(IC::TypeToMap(*type, isolate())); | 862 Handle<Map> receiver_map(IC::TypeToMap(*type, isolate())); |
| 863 // Make sure that the type feedback oracle harvests the receiver map. |
| 864 // TODO(svenpanne) Remove this hack when all ICs are reworked. |
| 865 __ mov(scratch1, receiver_map); |
| 864 | 866 |
| 865 // Make sure there's no overlap between holder and object registers. | 867 // Make sure there's no overlap between holder and object registers. |
| 866 ASSERT(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); | 868 ASSERT(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); |
| 867 ASSERT(!scratch2.is(object_reg) && !scratch2.is(holder_reg) | 869 ASSERT(!scratch2.is(object_reg) && !scratch2.is(holder_reg) |
| 868 && !scratch2.is(scratch1)); | 870 && !scratch2.is(scratch1)); |
| 869 | 871 |
| 870 // Keep track of the current object in register reg. | 872 // Keep track of the current object in register reg. |
| 871 Register reg = object_reg; | 873 Register reg = object_reg; |
| 872 int depth = 0; | 874 int depth = 0; |
| 873 | 875 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 } else { | 1059 } else { |
| 1058 KeyedLoadFieldStub stub(field.is_inobject(holder), | 1060 KeyedLoadFieldStub stub(field.is_inobject(holder), |
| 1059 field.translate(holder), | 1061 field.translate(holder), |
| 1060 representation); | 1062 representation); |
| 1061 GenerateTailCall(masm(), stub.GetCode(isolate())); | 1063 GenerateTailCall(masm(), stub.GetCode(isolate())); |
| 1062 } | 1064 } |
| 1063 } | 1065 } |
| 1064 | 1066 |
| 1065 | 1067 |
| 1066 void LoadStubCompiler::GenerateLoadCallback( | 1068 void LoadStubCompiler::GenerateLoadCallback( |
| 1069 const CallOptimization& call_optimization, |
| 1070 Handle<Map> receiver_map) { |
| 1071 GenerateFastApiCall( |
| 1072 masm(), call_optimization, receiver_map, |
| 1073 receiver(), scratch1(), 0, NULL); |
| 1074 } |
| 1075 |
| 1076 |
| 1077 void LoadStubCompiler::GenerateLoadCallback( |
| 1067 Register reg, | 1078 Register reg, |
| 1068 Handle<ExecutableAccessorInfo> callback) { | 1079 Handle<ExecutableAccessorInfo> callback) { |
| 1069 // Insert additional parameters into the stack frame above return address. | 1080 // Insert additional parameters into the stack frame above return address. |
| 1070 ASSERT(!scratch3().is(reg)); | 1081 ASSERT(!scratch3().is(reg)); |
| 1071 __ pop(scratch3()); // Get return address to place it below. | 1082 __ pop(scratch3()); // Get return address to place it below. |
| 1072 | 1083 |
| 1073 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0); | 1084 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0); |
| 1074 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1); | 1085 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1); |
| 1075 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2); | 1086 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2); |
| 1076 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3); | 1087 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 // Do tail-call to the runtime system. | 1256 // Do tail-call to the runtime system. |
| 1246 ExternalReference store_callback_property = | 1257 ExternalReference store_callback_property = |
| 1247 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate()); | 1258 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate()); |
| 1248 __ TailCallExternalReference(store_callback_property, 5, 1); | 1259 __ TailCallExternalReference(store_callback_property, 5, 1); |
| 1249 | 1260 |
| 1250 // Return the generated code. | 1261 // Return the generated code. |
| 1251 return GetCode(kind(), Code::FAST, name); | 1262 return GetCode(kind(), Code::FAST, name); |
| 1252 } | 1263 } |
| 1253 | 1264 |
| 1254 | 1265 |
| 1266 Handle<Code> StoreStubCompiler::CompileStoreCallback( |
| 1267 Handle<JSObject> object, |
| 1268 Handle<JSObject> holder, |
| 1269 Handle<Name> name, |
| 1270 const CallOptimization& call_optimization) { |
| 1271 HandlerFrontend(IC::CurrentTypeOf(object, isolate()), |
| 1272 receiver(), holder, name); |
| 1273 |
| 1274 Register values[] = { value() }; |
| 1275 GenerateFastApiCall( |
| 1276 masm(), call_optimization, handle(object->map()), |
| 1277 receiver(), scratch1(), 1, values); |
| 1278 |
| 1279 // Return the generated code. |
| 1280 return GetCode(kind(), Code::FAST, name); |
| 1281 } |
| 1282 |
| 1283 |
| 1255 #undef __ | 1284 #undef __ |
| 1256 #define __ ACCESS_MASM(masm) | 1285 #define __ ACCESS_MASM(masm) |
| 1257 | 1286 |
| 1258 | 1287 |
| 1259 void StoreStubCompiler::GenerateStoreViaSetter( | 1288 void StoreStubCompiler::GenerateStoreViaSetter( |
| 1260 MacroAssembler* masm, | 1289 MacroAssembler* masm, |
| 1261 Handle<HeapType> type, | 1290 Handle<HeapType> type, |
| 1262 Handle<JSFunction> setter) { | 1291 Handle<JSFunction> setter) { |
| 1263 // ----------- S t a t e ------------- | 1292 // ----------- S t a t e ------------- |
| 1264 // -- eax : value | 1293 // -- eax : value |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1568 // ----------------------------------- | 1597 // ----------------------------------- |
| 1569 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 1598 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
| 1570 } | 1599 } |
| 1571 | 1600 |
| 1572 | 1601 |
| 1573 #undef __ | 1602 #undef __ |
| 1574 | 1603 |
| 1575 } } // namespace v8::internal | 1604 } } // namespace v8::internal |
| 1576 | 1605 |
| 1577 #endif // V8_TARGET_ARCH_IA32 | 1606 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |