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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 Immediate(reinterpret_cast<int>(masm->isolate()))); | 496 Immediate(reinterpret_cast<int>(masm->isolate()))); |
497 __ mov(Operand(esp, 5 * kPointerSize), | 497 __ mov(Operand(esp, 5 * kPointerSize), |
498 masm->isolate()->factory()->undefined_value()); | 498 masm->isolate()->factory()->undefined_value()); |
499 __ mov(Operand(esp, 6 * kPointerSize), | 499 __ mov(Operand(esp, 6 * kPointerSize), |
500 masm->isolate()->factory()->undefined_value()); | 500 masm->isolate()->factory()->undefined_value()); |
501 | 501 |
502 // Prepare arguments. | 502 // Prepare arguments. |
503 STATIC_ASSERT(kFastApiCallArguments == 6); | 503 STATIC_ASSERT(kFastApiCallArguments == 6); |
504 __ lea(eax, Operand(esp, kFastApiCallArguments * kPointerSize)); | 504 __ lea(eax, Operand(esp, kFastApiCallArguments * kPointerSize)); |
505 | 505 |
506 const int kApiArgc = 1; // API function gets reference to the v8::Arguments. | 506 |
| 507 // API function gets reference to the v8::Arguments. If CPU profiler |
| 508 // is enabled wrapper function will be called and we need to pass |
| 509 // address of the callback as additional parameter, always allocate |
| 510 // space for it. |
| 511 const int kApiArgc = 1 + 1; |
507 | 512 |
508 // Allocate the v8::Arguments structure in the arguments' space since | 513 // Allocate the v8::Arguments structure in the arguments' space since |
509 // it's not controlled by GC. | 514 // it's not controlled by GC. |
510 const int kApiStackSpace = 4; | 515 const int kApiStackSpace = 4; |
511 | 516 |
512 // Function address is a foreign pointer outside V8's heap. | 517 // Function address is a foreign pointer outside V8's heap. |
513 Address function_address = v8::ToCData<Address>(api_call_info->callback()); | 518 Address function_address = v8::ToCData<Address>(api_call_info->callback()); |
514 bool returns_handle = | 519 bool returns_handle = |
515 !CallbackTable::ReturnsVoid(masm->isolate(), | 520 !CallbackTable::ReturnsVoid(masm->isolate(), |
516 reinterpret_cast<void*>(function_address)); | 521 reinterpret_cast<void*>(function_address)); |
517 __ PrepareCallApiFunction(kApiArgc + kApiStackSpace, returns_handle); | 522 __ PrepareCallApiFunction(kApiArgc + kApiStackSpace, returns_handle); |
518 | 523 |
519 // v8::Arguments::implicit_args_. | 524 // v8::Arguments::implicit_args_. |
520 __ mov(ApiParameterOperand(1, returns_handle), eax); | 525 __ mov(ApiParameterOperand(2, returns_handle), eax); |
521 __ add(eax, Immediate(argc * kPointerSize)); | 526 __ add(eax, Immediate(argc * kPointerSize)); |
522 // v8::Arguments::values_. | 527 // v8::Arguments::values_. |
523 __ mov(ApiParameterOperand(2, returns_handle), eax); | 528 __ mov(ApiParameterOperand(3, returns_handle), eax); |
524 // v8::Arguments::length_. | 529 // v8::Arguments::length_. |
525 __ Set(ApiParameterOperand(3, returns_handle), Immediate(argc)); | 530 __ Set(ApiParameterOperand(4, returns_handle), Immediate(argc)); |
526 // v8::Arguments::is_construct_call_. | 531 // v8::Arguments::is_construct_call_. |
527 __ Set(ApiParameterOperand(4, returns_handle), Immediate(0)); | 532 __ Set(ApiParameterOperand(5, returns_handle), Immediate(0)); |
528 | 533 |
529 // v8::InvocationCallback's argument. | 534 // v8::InvocationCallback's argument. |
530 __ lea(eax, ApiParameterOperand(1, returns_handle)); | 535 __ lea(eax, ApiParameterOperand(2, returns_handle)); |
531 __ mov(ApiParameterOperand(0, returns_handle), eax); | 536 __ mov(ApiParameterOperand(0, returns_handle), eax); |
532 | 537 |
| 538 Address thunk_address = returns_handle |
| 539 ? FUNCTION_ADDR(&InvokeInvocationCallback) |
| 540 : FUNCTION_ADDR(&InvokeFunctionCallback); |
| 541 |
533 __ CallApiFunctionAndReturn(function_address, | 542 __ CallApiFunctionAndReturn(function_address, |
| 543 thunk_address, |
| 544 ApiParameterOperand(1, returns_handle), |
534 argc + kFastApiCallArguments + 1, | 545 argc + kFastApiCallArguments + 1, |
535 returns_handle, | 546 returns_handle, |
536 kFastApiCallArguments + 1); | 547 kFastApiCallArguments + 1); |
537 } | 548 } |
538 | 549 |
539 | 550 |
540 class CallInterceptorCompiler BASE_EMBEDDED { | 551 class CallInterceptorCompiler BASE_EMBEDDED { |
541 public: | 552 public: |
542 CallInterceptorCompiler(StubCompiler* stub_compiler, | 553 CallInterceptorCompiler(StubCompiler* stub_compiler, |
543 const ParameterCount& arguments, | 554 const ParameterCount& arguments, |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 __ push(scratch2()); | 1419 __ push(scratch2()); |
1409 | 1420 |
1410 __ push(name()); // name | 1421 __ push(name()); // name |
1411 __ mov(ebx, esp); // esp points to reference to name (handler). | 1422 __ mov(ebx, esp); // esp points to reference to name (handler). |
1412 | 1423 |
1413 __ push(scratch3()); // Restore return address. | 1424 __ push(scratch3()); // Restore return address. |
1414 | 1425 |
1415 // array for v8::Arguments::values_, handler for name and pointer | 1426 // array for v8::Arguments::values_, handler for name and pointer |
1416 // to the values (it considered as smi in GC). | 1427 // to the values (it considered as smi in GC). |
1417 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 2; | 1428 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 2; |
1418 const int kApiArgc = 2; | 1429 // Allocate space for opional callback address parameter in case |
| 1430 // CPU profiler is active. |
| 1431 const int kApiArgc = 2 + 1; |
1419 | 1432 |
1420 Address getter_address = v8::ToCData<Address>(callback->getter()); | 1433 Address getter_address = v8::ToCData<Address>(callback->getter()); |
1421 bool returns_handle = | 1434 bool returns_handle = |
1422 !CallbackTable::ReturnsVoid(isolate(), | 1435 !CallbackTable::ReturnsVoid(isolate(), |
1423 reinterpret_cast<void*>(getter_address)); | 1436 reinterpret_cast<void*>(getter_address)); |
1424 __ PrepareCallApiFunction(kApiArgc, returns_handle); | 1437 __ PrepareCallApiFunction(kApiArgc, returns_handle); |
1425 __ mov(ApiParameterOperand(0, returns_handle), ebx); // name. | 1438 __ mov(ApiParameterOperand(0, returns_handle), ebx); // name. |
1426 __ add(ebx, Immediate(kPointerSize)); | 1439 __ add(ebx, Immediate(kPointerSize)); |
1427 __ mov(ApiParameterOperand(1, returns_handle), ebx); // arguments pointer. | 1440 __ mov(ApiParameterOperand(1, returns_handle), ebx); // arguments pointer. |
1428 | 1441 |
1429 // Emitting a stub call may try to allocate (if the code is not | 1442 // Emitting a stub call may try to allocate (if the code is not |
1430 // already generated). Do not allow the assembler to perform a | 1443 // already generated). Do not allow the assembler to perform a |
1431 // garbage collection but instead return the allocation failure | 1444 // garbage collection but instead return the allocation failure |
1432 // object. | 1445 // object. |
1433 | 1446 |
| 1447 Address thunk_address = returns_handle |
| 1448 ? FUNCTION_ADDR(&InvokeAccessorGetter) |
| 1449 : FUNCTION_ADDR(&InvokeAccessorGetterCallback); |
| 1450 |
1434 __ CallApiFunctionAndReturn(getter_address, | 1451 __ CallApiFunctionAndReturn(getter_address, |
| 1452 thunk_address, |
| 1453 ApiParameterOperand(2, returns_handle), |
1435 kStackSpace, | 1454 kStackSpace, |
1436 returns_handle, | 1455 returns_handle, |
1437 6); | 1456 6); |
1438 } | 1457 } |
1439 | 1458 |
1440 | 1459 |
1441 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<JSFunction> value) { | 1460 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<JSFunction> value) { |
1442 // Return the constant value. | 1461 // Return the constant value. |
1443 __ LoadHeapObject(eax, value); | 1462 __ LoadHeapObject(eax, value); |
1444 __ ret(0); | 1463 __ ret(0); |
(...skipping 2307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3752 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); | 3771 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); |
3753 } | 3772 } |
3754 } | 3773 } |
3755 | 3774 |
3756 | 3775 |
3757 #undef __ | 3776 #undef __ |
3758 | 3777 |
3759 } } // namespace v8::internal | 3778 } } // namespace v8::internal |
3760 | 3779 |
3761 #endif // V8_TARGET_ARCH_IA32 | 3780 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |