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 | 506 const int kApiArgc = 1; // API function gets reference to the v8::Arguments. |
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; | |
512 | 507 |
513 // Allocate the v8::Arguments structure in the arguments' space since | 508 // Allocate the v8::Arguments structure in the arguments' space since |
514 // it's not controlled by GC. | 509 // it's not controlled by GC. |
515 const int kApiStackSpace = 4; | 510 const int kApiStackSpace = 4; |
516 | 511 |
517 // Function address is a foreign pointer outside V8's heap. | 512 // Function address is a foreign pointer outside V8's heap. |
518 Address function_address = v8::ToCData<Address>(api_call_info->callback()); | 513 Address function_address = v8::ToCData<Address>(api_call_info->callback()); |
519 bool returns_handle = | 514 bool returns_handle = |
520 !CallbackTable::ReturnsVoid(masm->isolate(), | 515 !CallbackTable::ReturnsVoid(masm->isolate(), |
521 reinterpret_cast<void*>(function_address)); | 516 reinterpret_cast<void*>(function_address)); |
522 __ PrepareCallApiFunction(kApiArgc + kApiStackSpace, returns_handle); | 517 __ PrepareCallApiFunction(kApiArgc + kApiStackSpace, returns_handle); |
523 | 518 |
524 // v8::Arguments::implicit_args_. | 519 // v8::Arguments::implicit_args_. |
525 __ mov(ApiParameterOperand(2, returns_handle), eax); | 520 __ mov(ApiParameterOperand(1, returns_handle), eax); |
526 __ add(eax, Immediate(argc * kPointerSize)); | 521 __ add(eax, Immediate(argc * kPointerSize)); |
527 // v8::Arguments::values_. | 522 // v8::Arguments::values_. |
528 __ mov(ApiParameterOperand(3, returns_handle), eax); | 523 __ mov(ApiParameterOperand(2, returns_handle), eax); |
529 // v8::Arguments::length_. | 524 // v8::Arguments::length_. |
530 __ Set(ApiParameterOperand(4, returns_handle), Immediate(argc)); | 525 __ Set(ApiParameterOperand(3, returns_handle), Immediate(argc)); |
531 // v8::Arguments::is_construct_call_. | 526 // v8::Arguments::is_construct_call_. |
532 __ Set(ApiParameterOperand(5, returns_handle), Immediate(0)); | 527 __ Set(ApiParameterOperand(4, returns_handle), Immediate(0)); |
533 | 528 |
534 // v8::InvocationCallback's argument. | 529 // v8::InvocationCallback's argument. |
535 __ lea(eax, ApiParameterOperand(2, returns_handle)); | 530 __ lea(eax, ApiParameterOperand(1, returns_handle)); |
536 __ mov(ApiParameterOperand(0, returns_handle), eax); | 531 __ mov(ApiParameterOperand(0, returns_handle), eax); |
537 | 532 |
538 Address thunk_address = returns_handle | |
539 ? FUNCTION_ADDR(&InvokeInvocationCallback) | |
540 : FUNCTION_ADDR(&InvokeFunctionCallback); | |
541 | |
542 __ CallApiFunctionAndReturn(function_address, | 533 __ CallApiFunctionAndReturn(function_address, |
543 thunk_address, | |
544 ApiParameterOperand(1, returns_handle), | |
545 argc + kFastApiCallArguments + 1, | 534 argc + kFastApiCallArguments + 1, |
546 returns_handle, | 535 returns_handle, |
547 kFastApiCallArguments + 1); | 536 kFastApiCallArguments + 1); |
548 } | 537 } |
549 | 538 |
550 | 539 |
551 class CallInterceptorCompiler BASE_EMBEDDED { | 540 class CallInterceptorCompiler BASE_EMBEDDED { |
552 public: | 541 public: |
553 CallInterceptorCompiler(StubCompiler* stub_compiler, | 542 CallInterceptorCompiler(StubCompiler* stub_compiler, |
554 const ParameterCount& arguments, | 543 const ParameterCount& arguments, |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 __ push(scratch2()); | 1399 __ push(scratch2()); |
1411 | 1400 |
1412 __ push(name()); // name | 1401 __ push(name()); // name |
1413 __ mov(ebx, esp); // esp points to reference to name (handler). | 1402 __ mov(ebx, esp); // esp points to reference to name (handler). |
1414 | 1403 |
1415 __ push(scratch3()); // Restore return address. | 1404 __ push(scratch3()); // Restore return address. |
1416 | 1405 |
1417 // array for v8::Arguments::values_, handler for name and pointer | 1406 // array for v8::Arguments::values_, handler for name and pointer |
1418 // to the values (it considered as smi in GC). | 1407 // to the values (it considered as smi in GC). |
1419 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 2; | 1408 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 2; |
1420 // Allocate space for opional callback address parameter in case | 1409 const int kApiArgc = 2; |
1421 // CPU profiler is active. | |
1422 const int kApiArgc = 2 + 1; | |
1423 | 1410 |
1424 Address getter_address = v8::ToCData<Address>(callback->getter()); | 1411 Address getter_address = v8::ToCData<Address>(callback->getter()); |
1425 bool returns_handle = | 1412 bool returns_handle = |
1426 !CallbackTable::ReturnsVoid(isolate(), | 1413 !CallbackTable::ReturnsVoid(isolate(), |
1427 reinterpret_cast<void*>(getter_address)); | 1414 reinterpret_cast<void*>(getter_address)); |
1428 __ PrepareCallApiFunction(kApiArgc, returns_handle); | 1415 __ PrepareCallApiFunction(kApiArgc, returns_handle); |
1429 __ mov(ApiParameterOperand(0, returns_handle), ebx); // name. | 1416 __ mov(ApiParameterOperand(0, returns_handle), ebx); // name. |
1430 __ add(ebx, Immediate(kPointerSize)); | 1417 __ add(ebx, Immediate(kPointerSize)); |
1431 __ mov(ApiParameterOperand(1, returns_handle), ebx); // arguments pointer. | 1418 __ mov(ApiParameterOperand(1, returns_handle), ebx); // arguments pointer. |
1432 | 1419 |
1433 // Emitting a stub call may try to allocate (if the code is not | 1420 // Emitting a stub call may try to allocate (if the code is not |
1434 // already generated). Do not allow the assembler to perform a | 1421 // already generated). Do not allow the assembler to perform a |
1435 // garbage collection but instead return the allocation failure | 1422 // garbage collection but instead return the allocation failure |
1436 // object. | 1423 // object. |
1437 | 1424 |
1438 Address thunk_address = returns_handle | |
1439 ? FUNCTION_ADDR(&InvokeAccessorGetter) | |
1440 : FUNCTION_ADDR(&InvokeAccessorGetterCallback); | |
1441 | |
1442 __ CallApiFunctionAndReturn(getter_address, | 1425 __ CallApiFunctionAndReturn(getter_address, |
1443 thunk_address, | |
1444 ApiParameterOperand(2, returns_handle), | |
1445 kStackSpace, | 1426 kStackSpace, |
1446 returns_handle, | 1427 returns_handle, |
1447 6); | 1428 6); |
1448 } | 1429 } |
1449 | 1430 |
1450 | 1431 |
1451 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<JSFunction> value) { | 1432 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<JSFunction> value) { |
1452 // Return the constant value. | 1433 // Return the constant value. |
1453 __ LoadHeapObject(eax, value); | 1434 __ LoadHeapObject(eax, value); |
1454 __ ret(0); | 1435 __ ret(0); |
(...skipping 2307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3762 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); | 3743 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); |
3763 } | 3744 } |
3764 } | 3745 } |
3765 | 3746 |
3766 | 3747 |
3767 #undef __ | 3748 #undef __ |
3768 | 3749 |
3769 } } // namespace v8::internal | 3750 } } // namespace v8::internal |
3770 | 3751 |
3771 #endif // V8_TARGET_ARCH_IA32 | 3752 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |