Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1642)

Side by Side Diff: src/ia32/stub-cache-ia32.cc

Issue 12494012: new style of property/function callbacks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: account for apiparameteroperand changes Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/isolate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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. 530 int return_value_offset = FunctionCallbackArguments::kArgsLength +
519 Address function_address = v8::ToCData<Address>(api_call_info->callback()); 531 FunctionCallbackArguments::kReturnValueOffset;
520 __ CallApiFunctionAndReturn(function_address, 532 __ CallApiFunctionAndReturn(function_address,
521 argc + kFastApiCallArguments + 1); 533 argc + kFastApiCallArguments + 1,
534 returns_handle,
535 0,
536 return_value_offset);
522 } 537 }
523 538
524 539
525 class CallInterceptorCompiler BASE_EMBEDDED { 540 class CallInterceptorCompiler BASE_EMBEDDED {
526 public: 541 public:
527 CallInterceptorCompiler(StubCompiler* stub_compiler, 542 CallInterceptorCompiler(StubCompiler* stub_compiler,
528 const ParameterCount& arguments, 543 const ParameterCount& arguments,
529 Register name, 544 Register name,
530 Code::ExtraICState extra_state) 545 Code::ExtraICState extra_state)
531 : stub_compiler_(stub_compiler), 546 : stub_compiler_(stub_compiler),
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 ASSERT(!scratch2().is(reg)); 1373 ASSERT(!scratch2().is(reg));
1359 __ push(reg); // holder 1374 __ push(reg); // holder
1360 // Push data from ExecutableAccessorInfo. 1375 // Push data from ExecutableAccessorInfo.
1361 if (isolate()->heap()->InNewSpace(callback->data())) { 1376 if (isolate()->heap()->InNewSpace(callback->data())) {
1362 __ mov(scratch1(), Immediate(callback)); 1377 __ mov(scratch1(), Immediate(callback));
1363 __ push(FieldOperand(scratch1(), ExecutableAccessorInfo::kDataOffset)); 1378 __ push(FieldOperand(scratch1(), ExecutableAccessorInfo::kDataOffset));
1364 } else { 1379 } else {
1365 __ push(Immediate(Handle<Object>(callback->data(), isolate()))); 1380 __ push(Immediate(Handle<Object>(callback->data(), isolate())));
1366 } 1381 }
1367 __ push(Immediate(reinterpret_cast<int>(isolate()))); 1382 __ push(Immediate(reinterpret_cast<int>(isolate())));
1383 __ push(Immediate(isolate()->factory()->undefined_value())); // ReturnValue
1368 1384
1369 // Save a pointer to where we pushed the arguments pointer. This will be 1385 // Save a pointer to where we pushed the arguments pointer. This will be
1370 // passed as the const ExecutableAccessorInfo& to the C++ callback. 1386 // passed as the const ExecutableAccessorInfo& to the C++ callback.
1371 __ push(scratch2()); 1387 __ push(scratch2());
1372 1388
1373 __ push(name()); // name 1389 __ push(name()); // name
1374 __ mov(ebx, esp); // esp points to reference to name (handler). 1390 __ mov(ebx, esp); // esp points to reference to name (handler).
1375 1391
1376 __ push(scratch3()); // Restore return address. 1392 __ push(scratch3()); // Restore return address.
1377 1393
1378 // 4 elements array for v8::Arguments::values_, handler for name and pointer 1394 // array for v8::Arguments::values_, handler for name and pointer
1379 // to the values (it considered as smi in GC). 1395 // to the values (it considered as smi in GC).
1380 const int kStackSpace = 6; 1396 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 2;
1381 const int kApiArgc = 2; 1397 const int kApiArgc = 2;
1382 1398
1383 __ PrepareCallApiFunction(kApiArgc); 1399 Address getter_address = v8::ToCData<Address>(callback->getter());
1384 __ mov(ApiParameterOperand(0), ebx); // name. 1400 bool returns_handle =
1401 !CallbackTable::ReturnsVoid(isolate(),
1402 reinterpret_cast<void*>(getter_address));
1403 __ PrepareCallApiFunction(kApiArgc, returns_handle);
1404 __ mov(ApiParameterOperand(0, returns_handle), ebx); // name.
1385 __ add(ebx, Immediate(kPointerSize)); 1405 __ add(ebx, Immediate(kPointerSize));
1386 __ mov(ApiParameterOperand(1), ebx); // arguments pointer. 1406 __ mov(ApiParameterOperand(1, returns_handle), ebx); // arguments pointer.
1387 1407
1388 // Emitting a stub call may try to allocate (if the code is not 1408 // Emitting a stub call may try to allocate (if the code is not
1389 // already generated). Do not allow the assembler to perform a 1409 // already generated). Do not allow the assembler to perform a
1390 // garbage collection but instead return the allocation failure 1410 // garbage collection but instead return the allocation failure
1391 // object. 1411 // object.
1392 Address getter_address = v8::ToCData<Address>(callback->getter()); 1412
1393 __ CallApiFunctionAndReturn(getter_address, kStackSpace); 1413 int return_value_offset = PropertyCallbackArguments::kArgsLength +
1414 PropertyCallbackArguments::kReturnValueOffset;
1415 __ CallApiFunctionAndReturn(getter_address,
1416 kStackSpace,
1417 returns_handle,
1418 1,
1419 return_value_offset);
1394 } 1420 }
1395 1421
1396 1422
1397 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<JSFunction> value) { 1423 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<JSFunction> value) {
1398 // Return the constant value. 1424 // Return the constant value.
1399 __ LoadHeapObject(eax, value); 1425 __ LoadHeapObject(eax, value);
1400 __ ret(0); 1426 __ ret(0);
1401 } 1427 }
1402 1428
1403 1429
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
2486 2512
2487 // Allocate space for v8::Arguments implicit values. Must be initialized 2513 // Allocate space for v8::Arguments implicit values. Must be initialized
2488 // before calling any runtime function. 2514 // before calling any runtime function.
2489 __ sub(esp, Immediate(kFastApiCallArguments * kPointerSize)); 2515 __ sub(esp, Immediate(kFastApiCallArguments * kPointerSize));
2490 2516
2491 // Check that the maps haven't changed and find a Holder as a side effect. 2517 // 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, 2518 CheckPrototypes(Handle<JSObject>::cast(object), edx, holder, ebx, eax, edi,
2493 name, depth, &miss); 2519 name, depth, &miss);
2494 2520
2495 // Move the return address on top of the stack. 2521 // Move the return address on top of the stack.
2496 __ mov(eax, Operand(esp, 4 * kPointerSize)); 2522 __ mov(eax, Operand(esp, kFastApiCallArguments * kPointerSize));
2497 __ mov(Operand(esp, 0 * kPointerSize), eax); 2523 __ mov(Operand(esp, 0 * kPointerSize), eax);
2498 2524
2499 // esp[2 * kPointerSize] is uninitialized, esp[3 * kPointerSize] contains 2525 // esp[2 * kPointerSize] is uninitialized, esp[3 * kPointerSize] contains
2500 // duplicate of return address and will be overwritten. 2526 // duplicate of return address and will be overwritten.
2501 GenerateFastApiCall(masm(), optimization, argc); 2527 GenerateFastApiCall(masm(), optimization, argc);
2502 2528
2503 __ bind(&miss); 2529 __ bind(&miss);
2504 __ add(esp, Immediate(kFastApiCallArguments * kPointerSize)); 2530 __ add(esp, Immediate(kFastApiCallArguments * kPointerSize));
2505 2531
2506 __ bind(&miss_before_stack_reserved); 2532 __ bind(&miss_before_stack_reserved);
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after
3848 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); 3874 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
3849 } 3875 }
3850 } 3876 }
3851 3877
3852 3878
3853 #undef __ 3879 #undef __
3854 3880
3855 } } // namespace v8::internal 3881 } } // namespace v8::internal
3856 3882
3857 #endif // V8_TARGET_ARCH_IA32 3883 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698