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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 Handle<JSObject> holder_obj) { | 413 Handle<JSObject> holder_obj) { |
414 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); | 414 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); |
415 __ CallExternalReference( | 415 __ CallExternalReference( |
416 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorOnly), | 416 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorOnly), |
417 masm->isolate()), | 417 masm->isolate()), |
418 6); | 418 6); |
419 } | 419 } |
420 | 420 |
421 | 421 |
422 // Number of pointers to be reserved on stack for fast API call. | 422 // Number of pointers to be reserved on stack for fast API call. |
423 static const int kFastApiCallArguments = 4; | 423 static const int kFastApiCallArguments = FunctionCallbackArguments::kArgsLength; |
424 | 424 |
425 | 425 |
426 // Reserves space for the extra arguments to API function in the | 426 // Reserves space for the extra arguments to API function in the |
427 // caller's frame. | 427 // caller's frame. |
428 // | 428 // |
429 // These arguments are set by CheckPrototypes and GenerateFastApiCall. | 429 // These arguments are set by CheckPrototypes and GenerateFastApiCall. |
430 static void ReserveSpaceForFastApiCall(MacroAssembler* masm, Register scratch) { | 430 static void ReserveSpaceForFastApiCall(MacroAssembler* masm, Register scratch) { |
431 // ----------- S t a t e ------------- | 431 // ----------- S t a t e ------------- |
432 // -- esp[0] : return address | 432 // -- esp[0] : return address |
433 // -- esp[4] : last argument in the internal frame of the caller | 433 // -- esp[4] : last argument in the internal frame of the caller |
(...skipping 28 matching lines...) Expand all Loading... |
462 int argc) { | 462 int argc) { |
463 // ----------- S t a t e ------------- | 463 // ----------- S t a t e ------------- |
464 // -- esp[0] : return address | 464 // -- esp[0] : return address |
465 // -- esp[4] : object passing the type check | 465 // -- esp[4] : object passing the type check |
466 // (last fast api call extra argument, | 466 // (last fast api call extra argument, |
467 // set by CheckPrototypes) | 467 // set by CheckPrototypes) |
468 // -- esp[8] : api function | 468 // -- esp[8] : api function |
469 // (first fast api call extra argument) | 469 // (first fast api call extra argument) |
470 // -- esp[12] : api call data | 470 // -- esp[12] : api call data |
471 // -- esp[16] : isolate | 471 // -- esp[16] : isolate |
472 // -- esp[20] : last argument | 472 // -- esp[20] : ReturnValue |
| 473 // -- esp[24] : last argument |
473 // -- ... | 474 // -- ... |
474 // -- esp[(argc + 4) * 4] : first argument | 475 // -- esp[(argc + 5) * 4] : first argument |
475 // -- esp[(argc + 5) * 4] : receiver | 476 // -- esp[(argc + 6) * 4] : receiver |
476 // ----------------------------------- | 477 // ----------------------------------- |
477 // Get the function and setup the context. | 478 // Get the function and setup the context. |
478 Handle<JSFunction> function = optimization.constant_function(); | 479 Handle<JSFunction> function = optimization.constant_function(); |
479 __ LoadHeapObject(edi, function); | 480 __ LoadHeapObject(edi, function); |
480 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 481 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
481 | 482 |
482 // Pass the additional arguments. | 483 // Pass the additional arguments. |
483 __ mov(Operand(esp, 2 * kPointerSize), edi); | 484 __ mov(Operand(esp, 2 * kPointerSize), edi); |
484 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); | 485 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); |
485 Handle<Object> call_data(api_call_info->data(), masm->isolate()); | 486 Handle<Object> call_data(api_call_info->data(), masm->isolate()); |
486 if (masm->isolate()->heap()->InNewSpace(*call_data)) { | 487 if (masm->isolate()->heap()->InNewSpace(*call_data)) { |
487 __ mov(ecx, api_call_info); | 488 __ mov(ecx, api_call_info); |
488 __ mov(ebx, FieldOperand(ecx, CallHandlerInfo::kDataOffset)); | 489 __ mov(ebx, FieldOperand(ecx, CallHandlerInfo::kDataOffset)); |
489 __ mov(Operand(esp, 3 * kPointerSize), ebx); | 490 __ mov(Operand(esp, 3 * kPointerSize), ebx); |
490 } else { | 491 } else { |
491 __ mov(Operand(esp, 3 * kPointerSize), Immediate(call_data)); | 492 __ mov(Operand(esp, 3 * kPointerSize), Immediate(call_data)); |
492 } | 493 } |
493 __ mov(Operand(esp, 4 * kPointerSize), | 494 __ mov(Operand(esp, 4 * kPointerSize), |
494 Immediate(reinterpret_cast<int>(masm->isolate()))); | 495 Immediate(reinterpret_cast<int>(masm->isolate()))); |
| 496 __ mov(Operand(esp, 5 * kPointerSize), |
| 497 masm->isolate()->factory()->undefined_value()); |
495 | 498 |
496 // Prepare arguments. | 499 // Prepare arguments. |
497 __ lea(eax, Operand(esp, 4 * kPointerSize)); | 500 STATIC_ASSERT(kFastApiCallArguments == 5); |
| 501 __ lea(eax, Operand(esp, kFastApiCallArguments * kPointerSize)); |
498 | 502 |
499 const int kApiArgc = 1; // API function gets reference to the v8::Arguments. | 503 const int kApiArgc = 1; // API function gets reference to the v8::Arguments. |
500 | 504 |
501 // Allocate the v8::Arguments structure in the arguments' space since | 505 // Allocate the v8::Arguments structure in the arguments' space since |
502 // it's not controlled by GC. | 506 // it's not controlled by GC. |
503 const int kApiStackSpace = 4; | 507 const int kApiStackSpace = 4; |
504 | 508 |
505 __ PrepareCallApiFunction(kApiArgc + kApiStackSpace); | 509 // Function address is a foreign pointer outside V8's heap. |
| 510 Address function_address = v8::ToCData<Address>(api_call_info->callback()); |
| 511 bool returns_handle = |
| 512 !CallbackTable::ReturnsVoid(masm->isolate(), |
| 513 reinterpret_cast<void*>(function_address)); |
| 514 __ PrepareCallApiFunction(kApiArgc + kApiStackSpace, returns_handle); |
506 | 515 |
507 __ mov(ApiParameterOperand(1), eax); // v8::Arguments::implicit_args_. | 516 // v8::Arguments::implicit_args_. |
| 517 __ mov(ApiParameterOperand(1, returns_handle), eax); |
508 __ add(eax, Immediate(argc * kPointerSize)); | 518 __ add(eax, Immediate(argc * kPointerSize)); |
509 __ mov(ApiParameterOperand(2), eax); // v8::Arguments::values_. | 519 // v8::Arguments::values_. |
510 __ Set(ApiParameterOperand(3), Immediate(argc)); // v8::Arguments::length_. | 520 __ mov(ApiParameterOperand(2, returns_handle), eax); |
| 521 // v8::Arguments::length_. |
| 522 __ Set(ApiParameterOperand(3, returns_handle), Immediate(argc)); |
511 // v8::Arguments::is_construct_call_. | 523 // v8::Arguments::is_construct_call_. |
512 __ Set(ApiParameterOperand(4), Immediate(0)); | 524 __ Set(ApiParameterOperand(4, returns_handle), Immediate(0)); |
513 | 525 |
514 // v8::InvocationCallback's argument. | 526 // v8::InvocationCallback's argument. |
515 __ lea(eax, ApiParameterOperand(1)); | 527 __ lea(eax, ApiParameterOperand(1, returns_handle)); |
516 __ mov(ApiParameterOperand(0), eax); | 528 __ mov(ApiParameterOperand(0, returns_handle), eax); |
517 | 529 |
518 // Function address is a foreign pointer outside V8's heap. | |
519 Address function_address = v8::ToCData<Address>(api_call_info->callback()); | |
520 __ CallApiFunctionAndReturn(function_address, | 530 __ CallApiFunctionAndReturn(function_address, |
521 argc + kFastApiCallArguments + 1); | 531 argc + kFastApiCallArguments + 1, |
| 532 returns_handle, |
| 533 kFastApiCallArguments + 1); |
522 } | 534 } |
523 | 535 |
524 | 536 |
525 class CallInterceptorCompiler BASE_EMBEDDED { | 537 class CallInterceptorCompiler BASE_EMBEDDED { |
526 public: | 538 public: |
527 CallInterceptorCompiler(StubCompiler* stub_compiler, | 539 CallInterceptorCompiler(StubCompiler* stub_compiler, |
528 const ParameterCount& arguments, | 540 const ParameterCount& arguments, |
529 Register name, | 541 Register name, |
530 Code::ExtraICState extra_state) | 542 Code::ExtraICState extra_state) |
531 : stub_compiler_(stub_compiler), | 543 : stub_compiler_(stub_compiler), |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 ASSERT(!scratch2().is(reg)); | 1370 ASSERT(!scratch2().is(reg)); |
1359 __ push(reg); // holder | 1371 __ push(reg); // holder |
1360 // Push data from ExecutableAccessorInfo. | 1372 // Push data from ExecutableAccessorInfo. |
1361 if (isolate()->heap()->InNewSpace(callback->data())) { | 1373 if (isolate()->heap()->InNewSpace(callback->data())) { |
1362 __ mov(scratch1(), Immediate(callback)); | 1374 __ mov(scratch1(), Immediate(callback)); |
1363 __ push(FieldOperand(scratch1(), ExecutableAccessorInfo::kDataOffset)); | 1375 __ push(FieldOperand(scratch1(), ExecutableAccessorInfo::kDataOffset)); |
1364 } else { | 1376 } else { |
1365 __ push(Immediate(Handle<Object>(callback->data(), isolate()))); | 1377 __ push(Immediate(Handle<Object>(callback->data(), isolate()))); |
1366 } | 1378 } |
1367 __ push(Immediate(reinterpret_cast<int>(isolate()))); | 1379 __ push(Immediate(reinterpret_cast<int>(isolate()))); |
| 1380 __ push(Immediate(isolate()->factory()->undefined_value())); // ReturnValue |
1368 | 1381 |
1369 // Save a pointer to where we pushed the arguments pointer. This will be | 1382 // Save a pointer to where we pushed the arguments pointer. This will be |
1370 // passed as the const ExecutableAccessorInfo& to the C++ callback. | 1383 // passed as the const ExecutableAccessorInfo& to the C++ callback. |
1371 __ push(scratch2()); | 1384 __ push(scratch2()); |
1372 | 1385 |
1373 __ push(name()); // name | 1386 __ push(name()); // name |
1374 __ mov(ebx, esp); // esp points to reference to name (handler). | 1387 __ mov(ebx, esp); // esp points to reference to name (handler). |
1375 | 1388 |
1376 __ push(scratch3()); // Restore return address. | 1389 __ push(scratch3()); // Restore return address. |
1377 | 1390 |
1378 // 4 elements array for v8::Arguments::values_, handler for name and pointer | 1391 // array for v8::Arguments::values_, handler for name and pointer |
1379 // to the values (it considered as smi in GC). | 1392 // to the values (it considered as smi in GC). |
1380 const int kStackSpace = 6; | 1393 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 2; |
1381 const int kApiArgc = 2; | 1394 const int kApiArgc = 2; |
1382 | 1395 |
1383 __ PrepareCallApiFunction(kApiArgc); | 1396 Address getter_address = v8::ToCData<Address>(callback->getter()); |
1384 __ mov(ApiParameterOperand(0), ebx); // name. | 1397 bool returns_handle = |
| 1398 !CallbackTable::ReturnsVoid(isolate(), |
| 1399 reinterpret_cast<void*>(getter_address)); |
| 1400 __ PrepareCallApiFunction(kApiArgc, returns_handle); |
| 1401 __ mov(ApiParameterOperand(0, returns_handle), ebx); // name. |
1385 __ add(ebx, Immediate(kPointerSize)); | 1402 __ add(ebx, Immediate(kPointerSize)); |
1386 __ mov(ApiParameterOperand(1), ebx); // arguments pointer. | 1403 __ mov(ApiParameterOperand(1, returns_handle), ebx); // arguments pointer. |
1387 | 1404 |
1388 // Emitting a stub call may try to allocate (if the code is not | 1405 // Emitting a stub call may try to allocate (if the code is not |
1389 // already generated). Do not allow the assembler to perform a | 1406 // already generated). Do not allow the assembler to perform a |
1390 // garbage collection but instead return the allocation failure | 1407 // garbage collection but instead return the allocation failure |
1391 // object. | 1408 // object. |
1392 Address getter_address = v8::ToCData<Address>(callback->getter()); | 1409 |
1393 __ CallApiFunctionAndReturn(getter_address, kStackSpace); | 1410 __ CallApiFunctionAndReturn(getter_address, |
| 1411 kStackSpace, |
| 1412 returns_handle, |
| 1413 4); |
1394 } | 1414 } |
1395 | 1415 |
1396 | 1416 |
1397 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<JSFunction> value) { | 1417 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<JSFunction> value) { |
1398 // Return the constant value. | 1418 // Return the constant value. |
1399 __ LoadHeapObject(eax, value); | 1419 __ LoadHeapObject(eax, value); |
1400 __ ret(0); | 1420 __ ret(0); |
1401 } | 1421 } |
1402 | 1422 |
1403 | 1423 |
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2486 | 2506 |
2487 // Allocate space for v8::Arguments implicit values. Must be initialized | 2507 // Allocate space for v8::Arguments implicit values. Must be initialized |
2488 // before calling any runtime function. | 2508 // before calling any runtime function. |
2489 __ sub(esp, Immediate(kFastApiCallArguments * kPointerSize)); | 2509 __ sub(esp, Immediate(kFastApiCallArguments * kPointerSize)); |
2490 | 2510 |
2491 // Check that the maps haven't changed and find a Holder as a side effect. | 2511 // Check that the maps haven't changed and find a Holder as a side effect. |
2492 CheckPrototypes(Handle<JSObject>::cast(object), edx, holder, ebx, eax, edi, | 2512 CheckPrototypes(Handle<JSObject>::cast(object), edx, holder, ebx, eax, edi, |
2493 name, depth, &miss); | 2513 name, depth, &miss); |
2494 | 2514 |
2495 // Move the return address on top of the stack. | 2515 // Move the return address on top of the stack. |
2496 __ mov(eax, Operand(esp, 4 * kPointerSize)); | 2516 __ mov(eax, Operand(esp, kFastApiCallArguments * kPointerSize)); |
2497 __ mov(Operand(esp, 0 * kPointerSize), eax); | 2517 __ mov(Operand(esp, 0 * kPointerSize), eax); |
2498 | 2518 |
2499 // esp[2 * kPointerSize] is uninitialized, esp[3 * kPointerSize] contains | 2519 // esp[2 * kPointerSize] is uninitialized, esp[3 * kPointerSize] contains |
2500 // duplicate of return address and will be overwritten. | 2520 // duplicate of return address and will be overwritten. |
2501 GenerateFastApiCall(masm(), optimization, argc); | 2521 GenerateFastApiCall(masm(), optimization, argc); |
2502 | 2522 |
2503 __ bind(&miss); | 2523 __ bind(&miss); |
2504 __ add(esp, Immediate(kFastApiCallArguments * kPointerSize)); | 2524 __ add(esp, Immediate(kFastApiCallArguments * kPointerSize)); |
2505 | 2525 |
2506 __ bind(&miss_before_stack_reserved); | 2526 __ bind(&miss_before_stack_reserved); |
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3848 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); | 3868 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); |
3849 } | 3869 } |
3850 } | 3870 } |
3851 | 3871 |
3852 | 3872 |
3853 #undef __ | 3873 #undef __ |
3854 | 3874 |
3855 } } // namespace v8::internal | 3875 } } // namespace v8::internal |
3856 | 3876 |
3857 #endif // V8_TARGET_ARCH_IA32 | 3877 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |