| 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 11 matching lines...) Expand all Loading... |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #if V8_TARGET_ARCH_X64 | 30 #if V8_TARGET_ARCH_X64 |
| 31 | 31 |
| 32 #include "arguments.h" |
| 32 #include "ic-inl.h" | 33 #include "ic-inl.h" |
| 33 #include "codegen.h" | 34 #include "codegen.h" |
| 34 #include "stub-cache.h" | 35 #include "stub-cache.h" |
| 35 | 36 |
| 36 namespace v8 { | 37 namespace v8 { |
| 37 namespace internal { | 38 namespace internal { |
| 38 | 39 |
| 39 #define __ ACCESS_MASM(masm) | 40 #define __ ACCESS_MASM(masm) |
| 40 | 41 |
| 41 | 42 |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 } | 360 } |
| 360 __ movq(dst, FieldOperand(src, offset)); | 361 __ movq(dst, FieldOperand(src, offset)); |
| 361 } | 362 } |
| 362 | 363 |
| 363 | 364 |
| 364 static void PushInterceptorArguments(MacroAssembler* masm, | 365 static void PushInterceptorArguments(MacroAssembler* masm, |
| 365 Register receiver, | 366 Register receiver, |
| 366 Register holder, | 367 Register holder, |
| 367 Register name, | 368 Register name, |
| 368 Handle<JSObject> holder_obj) { | 369 Handle<JSObject> holder_obj) { |
| 370 STATIC_ASSERT(StubCache::kInterceptorArgsNameIndex == 0); |
| 371 STATIC_ASSERT(StubCache::kInterceptorArgsInfoIndex == 1); |
| 372 STATIC_ASSERT(StubCache::kInterceptorArgsThisIndex == 2); |
| 373 STATIC_ASSERT(StubCache::kInterceptorArgsHolderIndex == 3); |
| 374 STATIC_ASSERT(StubCache::kInterceptorArgsLength == 4); |
| 369 __ push(name); | 375 __ push(name); |
| 370 Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor()); | 376 Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor()); |
| 371 ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor)); | 377 ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor)); |
| 372 __ Move(kScratchRegister, interceptor); | 378 __ Move(kScratchRegister, interceptor); |
| 373 __ push(kScratchRegister); | 379 __ push(kScratchRegister); |
| 374 __ push(receiver); | 380 __ push(receiver); |
| 375 __ push(holder); | 381 __ push(holder); |
| 376 __ push(FieldOperand(kScratchRegister, InterceptorInfo::kDataOffset)); | |
| 377 __ PushAddress(ExternalReference::isolate_address(masm->isolate())); | |
| 378 } | 382 } |
| 379 | 383 |
| 380 | 384 |
| 381 static void CompileCallLoadPropertyWithInterceptor( | 385 static void CompileCallLoadPropertyWithInterceptor( |
| 382 MacroAssembler* masm, | 386 MacroAssembler* masm, |
| 383 Register receiver, | 387 Register receiver, |
| 384 Register holder, | 388 Register holder, |
| 385 Register name, | 389 Register name, |
| 386 Handle<JSObject> holder_obj) { | 390 Handle<JSObject> holder_obj) { |
| 387 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); | 391 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); |
| 388 | 392 |
| 389 ExternalReference ref = | 393 ExternalReference ref = |
| 390 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorOnly), | 394 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorOnly), |
| 391 masm->isolate()); | 395 masm->isolate()); |
| 392 __ Set(rax, 6); | 396 __ Set(rax, StubCache::kInterceptorArgsLength); |
| 393 __ LoadAddress(rbx, ref); | 397 __ LoadAddress(rbx, ref); |
| 394 | 398 |
| 395 CEntryStub stub(1); | 399 CEntryStub stub(1); |
| 396 __ CallStub(&stub); | 400 __ CallStub(&stub); |
| 397 } | 401 } |
| 398 | 402 |
| 399 | 403 |
| 400 // Number of pointers to be reserved on stack for fast API call. | 404 // Number of pointers to be reserved on stack for fast API call. |
| 401 static const int kFastApiCallArguments = FunctionCallbackArguments::kArgsLength; | 405 static const int kFastApiCallArguments = FunctionCallbackArguments::kArgsLength; |
| 402 | 406 |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 | 716 |
| 713 FrameScope scope(masm, StackFrame::INTERNAL); | 717 FrameScope scope(masm, StackFrame::INTERNAL); |
| 714 // Save the name_ register across the call. | 718 // Save the name_ register across the call. |
| 715 __ push(name_); | 719 __ push(name_); |
| 716 | 720 |
| 717 PushInterceptorArguments(masm, receiver, holder, name_, interceptor_holder); | 721 PushInterceptorArguments(masm, receiver, holder, name_, interceptor_holder); |
| 718 | 722 |
| 719 __ CallExternalReference( | 723 __ CallExternalReference( |
| 720 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorForCall), | 724 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorForCall), |
| 721 masm->isolate()), | 725 masm->isolate()), |
| 722 6); | 726 StubCache::kInterceptorArgsLength); |
| 723 | 727 |
| 724 // Restore the name_ register. | 728 // Restore the name_ register. |
| 725 __ pop(name_); | 729 __ pop(name_); |
| 726 | 730 |
| 727 // Leave the internal frame. | 731 // Leave the internal frame. |
| 728 } | 732 } |
| 729 | 733 |
| 730 void LoadWithInterceptor(MacroAssembler* masm, | 734 void LoadWithInterceptor(MacroAssembler* masm, |
| 731 Register receiver, | 735 Register receiver, |
| 732 Register holder, | 736 Register holder, |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 } | 1319 } |
| 1316 | 1320 |
| 1317 | 1321 |
| 1318 void BaseLoadStubCompiler::GenerateLoadCallback( | 1322 void BaseLoadStubCompiler::GenerateLoadCallback( |
| 1319 Register reg, | 1323 Register reg, |
| 1320 Handle<ExecutableAccessorInfo> callback) { | 1324 Handle<ExecutableAccessorInfo> callback) { |
| 1321 // Insert additional parameters into the stack frame above return address. | 1325 // Insert additional parameters into the stack frame above return address. |
| 1322 ASSERT(!scratch4().is(reg)); | 1326 ASSERT(!scratch4().is(reg)); |
| 1323 __ PopReturnAddressTo(scratch4()); | 1327 __ PopReturnAddressTo(scratch4()); |
| 1324 | 1328 |
| 1329 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 0); |
| 1330 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == -1); |
| 1331 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == -2); |
| 1332 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == -3); |
| 1333 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == -4); |
| 1334 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == -5); |
| 1325 __ push(receiver()); // receiver | 1335 __ push(receiver()); // receiver |
| 1326 __ push(reg); // holder | |
| 1327 if (heap()->InNewSpace(callback->data())) { | 1336 if (heap()->InNewSpace(callback->data())) { |
| 1328 __ Move(scratch1(), callback); | 1337 ASSERT(!scratch2().is(reg)); |
| 1329 __ push(FieldOperand(scratch1(), | 1338 __ Move(scratch2(), callback); |
| 1339 __ push(FieldOperand(scratch2(), |
| 1330 ExecutableAccessorInfo::kDataOffset)); // data | 1340 ExecutableAccessorInfo::kDataOffset)); // data |
| 1331 } else { | 1341 } else { |
| 1332 __ Push(Handle<Object>(callback->data(), isolate())); | 1342 __ Push(Handle<Object>(callback->data(), isolate())); |
| 1333 } | 1343 } |
| 1344 ASSERT(!kScratchRegister.is(reg)); |
| 1334 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); | 1345 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); |
| 1335 __ push(kScratchRegister); // return value | 1346 __ push(kScratchRegister); // return value |
| 1336 __ push(kScratchRegister); // return value default | 1347 __ push(kScratchRegister); // return value default |
| 1337 __ PushAddress(ExternalReference::isolate_address(isolate())); | 1348 __ PushAddress(ExternalReference::isolate_address(isolate())); |
| 1349 __ push(reg); // holder |
| 1338 __ push(name()); // name | 1350 __ push(name()); // name |
| 1339 // Save a pointer to where we pushed the arguments pointer. This will be | 1351 // Save a pointer to where we pushed the arguments pointer. This will be |
| 1340 // passed as the const ExecutableAccessorInfo& to the C++ callback. | 1352 // passed as the const ExecutableAccessorInfo& to the C++ callback. |
| 1341 | 1353 |
| 1342 Address getter_address = v8::ToCData<Address>(callback->getter()); | 1354 Address getter_address = v8::ToCData<Address>(callback->getter()); |
| 1343 | 1355 |
| 1344 #if defined(__MINGW64__) || defined(_WIN64) | 1356 #if defined(__MINGW64__) || defined(_WIN64) |
| 1345 Register getter_arg = r8; | 1357 Register getter_arg = r8; |
| 1346 Register accessor_info_arg = rdx; | 1358 Register accessor_info_arg = rdx; |
| 1347 Register name_arg = rcx; | 1359 Register name_arg = rcx; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1371 // The context register (rsi) has been saved in PrepareCallApiFunction and | 1383 // The context register (rsi) has been saved in PrepareCallApiFunction and |
| 1372 // could be used to pass arguments. | 1384 // could be used to pass arguments. |
| 1373 __ lea(accessor_info_arg, StackSpaceOperand(0)); | 1385 __ lea(accessor_info_arg, StackSpaceOperand(0)); |
| 1374 | 1386 |
| 1375 Address thunk_address = FUNCTION_ADDR(&InvokeAccessorGetterCallback); | 1387 Address thunk_address = FUNCTION_ADDR(&InvokeAccessorGetterCallback); |
| 1376 | 1388 |
| 1377 __ CallApiFunctionAndReturn(getter_address, | 1389 __ CallApiFunctionAndReturn(getter_address, |
| 1378 thunk_address, | 1390 thunk_address, |
| 1379 getter_arg, | 1391 getter_arg, |
| 1380 kStackSpace, | 1392 kStackSpace, |
| 1381 5); | 1393 6); |
| 1382 } | 1394 } |
| 1383 | 1395 |
| 1384 | 1396 |
| 1385 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<Object> value) { | 1397 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<Object> value) { |
| 1386 // Return the constant value. | 1398 // Return the constant value. |
| 1387 __ LoadObject(rax, value); | 1399 __ LoadObject(rax, value); |
| 1388 __ ret(0); | 1400 __ ret(0); |
| 1389 } | 1401 } |
| 1390 | 1402 |
| 1391 | 1403 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 } else { // !compile_followup_inline | 1482 } else { // !compile_followup_inline |
| 1471 // Call the runtime system to load the interceptor. | 1483 // Call the runtime system to load the interceptor. |
| 1472 // Check that the maps haven't changed. | 1484 // Check that the maps haven't changed. |
| 1473 __ PopReturnAddressTo(scratch2()); | 1485 __ PopReturnAddressTo(scratch2()); |
| 1474 PushInterceptorArguments(masm(), receiver(), holder_reg, | 1486 PushInterceptorArguments(masm(), receiver(), holder_reg, |
| 1475 this->name(), interceptor_holder); | 1487 this->name(), interceptor_holder); |
| 1476 __ PushReturnAddressFrom(scratch2()); | 1488 __ PushReturnAddressFrom(scratch2()); |
| 1477 | 1489 |
| 1478 ExternalReference ref = ExternalReference( | 1490 ExternalReference ref = ExternalReference( |
| 1479 IC_Utility(IC::kLoadPropertyWithInterceptorForLoad), isolate()); | 1491 IC_Utility(IC::kLoadPropertyWithInterceptorForLoad), isolate()); |
| 1480 __ TailCallExternalReference(ref, 6, 1); | 1492 __ TailCallExternalReference(ref, StubCache::kInterceptorArgsLength, 1); |
| 1481 } | 1493 } |
| 1482 } | 1494 } |
| 1483 | 1495 |
| 1484 | 1496 |
| 1485 void CallStubCompiler::GenerateNameCheck(Handle<Name> name, Label* miss) { | 1497 void CallStubCompiler::GenerateNameCheck(Handle<Name> name, Label* miss) { |
| 1486 if (kind_ == Code::KEYED_CALL_IC) { | 1498 if (kind_ == Code::KEYED_CALL_IC) { |
| 1487 __ Cmp(rcx, name); | 1499 __ Cmp(rcx, name); |
| 1488 __ j(not_equal, miss); | 1500 __ j(not_equal, miss); |
| 1489 } | 1501 } |
| 1490 } | 1502 } |
| (...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3150 // ----------------------------------- | 3162 // ----------------------------------- |
| 3151 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); | 3163 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); |
| 3152 } | 3164 } |
| 3153 | 3165 |
| 3154 | 3166 |
| 3155 #undef __ | 3167 #undef __ |
| 3156 | 3168 |
| 3157 } } // namespace v8::internal | 3169 } } // namespace v8::internal |
| 3158 | 3170 |
| 3159 #endif // V8_TARGET_ARCH_X64 | 3171 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |