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

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

Issue 12494012: new style of property/function callbacks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: make arm look like other architectures 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/x64/macro-assembler-x64.cc ('k') | test/cctest/test-api.cc » ('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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 masm->isolate()); 391 masm->isolate());
392 __ Set(rax, 6); 392 __ Set(rax, 6);
393 __ LoadAddress(rbx, ref); 393 __ LoadAddress(rbx, ref);
394 394
395 CEntryStub stub(1); 395 CEntryStub stub(1);
396 __ CallStub(&stub); 396 __ CallStub(&stub);
397 } 397 }
398 398
399 399
400 // Number of pointers to be reserved on stack for fast API call. 400 // Number of pointers to be reserved on stack for fast API call.
401 static const int kFastApiCallArguments = 4; 401 static const int kFastApiCallArguments = FunctionCallbackArguments::kArgsLength;
402 402
403 403
404 // Reserves space for the extra arguments to API function in the 404 // Reserves space for the extra arguments to API function in the
405 // caller's frame. 405 // caller's frame.
406 // 406 //
407 // These arguments are set by CheckPrototypes and GenerateFastApiCall. 407 // These arguments are set by CheckPrototypes and GenerateFastApiCall.
408 static void ReserveSpaceForFastApiCall(MacroAssembler* masm, Register scratch) { 408 static void ReserveSpaceForFastApiCall(MacroAssembler* masm, Register scratch) {
409 // ----------- S t a t e ------------- 409 // ----------- S t a t e -------------
410 // -- rsp[0] : return address 410 // -- rsp[0] : return address
411 // -- rsp[8] : last argument in the internal frame of the caller 411 // -- rsp[8] : last argument in the internal frame of the caller
(...skipping 30 matching lines...) Expand all
442 int argc) { 442 int argc) {
443 // ----------- S t a t e ------------- 443 // ----------- S t a t e -------------
444 // -- rsp[0] : return address 444 // -- rsp[0] : return address
445 // -- rsp[8] : object passing the type check 445 // -- rsp[8] : object passing the type check
446 // (last fast api call extra argument, 446 // (last fast api call extra argument,
447 // set by CheckPrototypes) 447 // set by CheckPrototypes)
448 // -- rsp[16] : api function 448 // -- rsp[16] : api function
449 // (first fast api call extra argument) 449 // (first fast api call extra argument)
450 // -- rsp[24] : api call data 450 // -- rsp[24] : api call data
451 // -- rsp[32] : isolate 451 // -- rsp[32] : isolate
452 // -- rsp[40] : last argument 452 // -- rsp[40] : ReturnValue
453 //
454 // -- rsp[48] : last argument
453 // -- ... 455 // -- ...
454 // -- rsp[(argc + 4) * 8] : first argument 456 // -- rsp[(argc + 5) * 8] : first argument
455 // -- rsp[(argc + 5) * 8] : receiver 457 // -- rsp[(argc + 6) * 8] : receiver
456 // ----------------------------------- 458 // -----------------------------------
457 // Get the function and setup the context. 459 // Get the function and setup the context.
458 Handle<JSFunction> function = optimization.constant_function(); 460 Handle<JSFunction> function = optimization.constant_function();
459 __ LoadHeapObject(rdi, function); 461 __ LoadHeapObject(rdi, function);
460 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); 462 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
461 463
462 // Pass the additional arguments. 464 // Pass the additional arguments.
463 __ movq(Operand(rsp, 2 * kPointerSize), rdi); 465 __ movq(Operand(rsp, 2 * kPointerSize), rdi);
464 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); 466 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info();
465 Handle<Object> call_data(api_call_info->data(), masm->isolate()); 467 Handle<Object> call_data(api_call_info->data(), masm->isolate());
466 if (masm->isolate()->heap()->InNewSpace(*call_data)) { 468 if (masm->isolate()->heap()->InNewSpace(*call_data)) {
467 __ Move(rcx, api_call_info); 469 __ Move(rcx, api_call_info);
468 __ movq(rbx, FieldOperand(rcx, CallHandlerInfo::kDataOffset)); 470 __ movq(rbx, FieldOperand(rcx, CallHandlerInfo::kDataOffset));
469 __ movq(Operand(rsp, 3 * kPointerSize), rbx); 471 __ movq(Operand(rsp, 3 * kPointerSize), rbx);
470 } else { 472 } else {
471 __ Move(Operand(rsp, 3 * kPointerSize), call_data); 473 __ Move(Operand(rsp, 3 * kPointerSize), call_data);
472 } 474 }
473 __ movq(kScratchRegister, 475 __ movq(kScratchRegister,
474 ExternalReference::isolate_address(masm->isolate())); 476 ExternalReference::isolate_address(masm->isolate()));
475 __ movq(Operand(rsp, 4 * kPointerSize), kScratchRegister); 477 __ movq(Operand(rsp, 4 * kPointerSize), kScratchRegister);
478 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex);
479 __ movq(Operand(rsp, 5 * kPointerSize), kScratchRegister);
476 480
477 // Prepare arguments. 481 // Prepare arguments.
478 __ lea(rbx, Operand(rsp, 4 * kPointerSize)); 482 STATIC_ASSERT(kFastApiCallArguments == 5);
483 __ lea(rbx, Operand(rsp, kFastApiCallArguments * kPointerSize));
484
485 // Function address is a foreign pointer outside V8's heap.
486 Address function_address = v8::ToCData<Address>(api_call_info->callback());
487 bool returns_handle =
488 !CallbackTable::ReturnsVoid(masm->isolate(), function_address);
479 489
480 #if defined(__MINGW64__) 490 #if defined(__MINGW64__)
481 Register arguments_arg = rcx; 491 Register arguments_arg = rcx;
482 #elif defined(_WIN64) 492 #elif defined(_WIN64)
483 // Win64 uses first register--rcx--for returned value. 493 // Win64 uses first register--rcx--for returned value.
484 Register arguments_arg = rdx; 494 Register arguments_arg = returns_handle ? rdx : rcx;
485 #else 495 #else
486 Register arguments_arg = rdi; 496 Register arguments_arg = rdi;
487 #endif 497 #endif
488 498
489 // Allocate the v8::Arguments structure in the arguments' space since 499 // Allocate the v8::Arguments structure in the arguments' space since
490 // it's not controlled by GC. 500 // it's not controlled by GC.
491 const int kApiStackSpace = 4; 501 const int kApiStackSpace = 4;
492 502
493 __ PrepareCallApiFunction(kApiStackSpace); 503 __ PrepareCallApiFunction(kApiStackSpace, returns_handle);
494 504
495 __ movq(StackSpaceOperand(0), rbx); // v8::Arguments::implicit_args_. 505 __ movq(StackSpaceOperand(0), rbx); // v8::Arguments::implicit_args_.
496 __ addq(rbx, Immediate(argc * kPointerSize)); 506 __ addq(rbx, Immediate(argc * kPointerSize));
497 __ movq(StackSpaceOperand(1), rbx); // v8::Arguments::values_. 507 __ movq(StackSpaceOperand(1), rbx); // v8::Arguments::values_.
498 __ Set(StackSpaceOperand(2), argc); // v8::Arguments::length_. 508 __ Set(StackSpaceOperand(2), argc); // v8::Arguments::length_.
499 // v8::Arguments::is_construct_call_. 509 // v8::Arguments::is_construct_call_.
500 __ Set(StackSpaceOperand(3), 0); 510 __ Set(StackSpaceOperand(3), 0);
501 511
502 // v8::InvocationCallback's argument. 512 // v8::InvocationCallback's argument.
503 __ lea(arguments_arg, StackSpaceOperand(0)); 513 __ lea(arguments_arg, StackSpaceOperand(0));
504 514
505 // Function address is a foreign pointer outside V8's heap.
506 Address function_address = v8::ToCData<Address>(api_call_info->callback());
507 __ CallApiFunctionAndReturn(function_address, 515 __ CallApiFunctionAndReturn(function_address,
508 argc + kFastApiCallArguments + 1); 516 argc + kFastApiCallArguments + 1,
517 returns_handle,
518 kFastApiCallArguments + 1);
509 } 519 }
510 520
511 521
512 class CallInterceptorCompiler BASE_EMBEDDED { 522 class CallInterceptorCompiler BASE_EMBEDDED {
513 public: 523 public:
514 CallInterceptorCompiler(StubCompiler* stub_compiler, 524 CallInterceptorCompiler(StubCompiler* stub_compiler,
515 const ParameterCount& arguments, 525 const ParameterCount& arguments,
516 Register name, 526 Register name,
517 Code::ExtraICState extra_ic_state) 527 Code::ExtraICState extra_ic_state)
518 : stub_compiler_(stub_compiler), 528 : stub_compiler_(stub_compiler),
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 1291
1282 __ push(receiver()); // receiver 1292 __ push(receiver()); // receiver
1283 __ push(reg); // holder 1293 __ push(reg); // holder
1284 if (heap()->InNewSpace(callback->data())) { 1294 if (heap()->InNewSpace(callback->data())) {
1285 __ Move(scratch1(), callback); 1295 __ Move(scratch1(), callback);
1286 __ push(FieldOperand(scratch1(), 1296 __ push(FieldOperand(scratch1(),
1287 ExecutableAccessorInfo::kDataOffset)); // data 1297 ExecutableAccessorInfo::kDataOffset)); // data
1288 } else { 1298 } else {
1289 __ Push(Handle<Object>(callback->data(), isolate())); 1299 __ Push(Handle<Object>(callback->data(), isolate()));
1290 } 1300 }
1291 __ PushAddress(ExternalReference::isolate_address(isolate())); // isolate 1301 __ PushAddress(ExternalReference::isolate_address(isolate()));
1302 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex);
1303 __ push(kScratchRegister); // return value
1292 __ push(name()); // name 1304 __ push(name()); // name
1293 // Save a pointer to where we pushed the arguments pointer. This will be 1305 // Save a pointer to where we pushed the arguments pointer. This will be
1294 // passed as the const ExecutableAccessorInfo& to the C++ callback. 1306 // passed as the const ExecutableAccessorInfo& to the C++ callback.
1295 1307
1308 Address getter_address = v8::ToCData<Address>(callback->getter());
1309 bool returns_handle =
1310 !CallbackTable::ReturnsVoid(isolate(), getter_address);
1311
1296 #if defined(__MINGW64__) 1312 #if defined(__MINGW64__)
1297 Register accessor_info_arg = rdx; 1313 Register accessor_info_arg = rdx;
1298 Register name_arg = rcx; 1314 Register name_arg = rcx;
1299 #elif defined(_WIN64) 1315 #elif defined(_WIN64)
1300 // Win64 uses first register--rcx--for returned value. 1316 // Win64 uses first register--rcx--for returned value.
1301 Register accessor_info_arg = r8; 1317 Register accessor_info_arg = returns_handle ? r8 : rdx;
1302 Register name_arg = rdx; 1318 Register name_arg = returns_handle ? rdx : rcx;
1303 #else 1319 #else
1304 Register accessor_info_arg = rsi; 1320 Register accessor_info_arg = rsi;
1305 Register name_arg = rdi; 1321 Register name_arg = rdi;
1306 #endif 1322 #endif
1307 1323
1308 ASSERT(!name_arg.is(scratch2())); 1324 ASSERT(!name_arg.is(scratch2()));
1309 __ movq(name_arg, rsp); 1325 __ movq(name_arg, rsp);
1310 __ push(scratch2()); // Restore return address. 1326 __ push(scratch2()); // Restore return address.
1311 1327
1312 // 4 elements array for v8::Arguments::values_ and handler for name. 1328 // v8::Arguments::values_ and handler for name.
1313 const int kStackSpace = 5; 1329 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 1;
1314 1330
1315 // Allocate v8::AccessorInfo in non-GCed stack space. 1331 // Allocate v8::AccessorInfo in non-GCed stack space.
1316 const int kArgStackSpace = 1; 1332 const int kArgStackSpace = 1;
1317 1333
1318 __ PrepareCallApiFunction(kArgStackSpace); 1334 __ PrepareCallApiFunction(kArgStackSpace, returns_handle);
1319 __ lea(rax, Operand(name_arg, 4 * kPointerSize)); 1335 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 5);
1336 __ lea(rax, Operand(name_arg, 5 * kPointerSize));
1320 1337
1321 // v8::AccessorInfo::args_. 1338 // v8::AccessorInfo::args_.
1322 __ movq(StackSpaceOperand(0), rax); 1339 __ movq(StackSpaceOperand(0), rax);
1323 1340
1324 // The context register (rsi) has been saved in PrepareCallApiFunction and 1341 // The context register (rsi) has been saved in PrepareCallApiFunction and
1325 // could be used to pass arguments. 1342 // could be used to pass arguments.
1326 __ lea(accessor_info_arg, StackSpaceOperand(0)); 1343 __ lea(accessor_info_arg, StackSpaceOperand(0));
1327 1344
1328 Address getter_address = v8::ToCData<Address>(callback->getter()); 1345 __ CallApiFunctionAndReturn(getter_address,
1329 __ CallApiFunctionAndReturn(getter_address, kStackSpace); 1346 kStackSpace,
1347 returns_handle,
1348 3);
1330 } 1349 }
1331 1350
1332 1351
1333 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<JSFunction> value) { 1352 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<JSFunction> value) {
1334 // Return the constant value. 1353 // Return the constant value.
1335 __ LoadHeapObject(rax, value); 1354 __ LoadHeapObject(rax, value);
1336 __ ret(0); 1355 __ ret(0);
1337 } 1356 }
1338 1357
1339 1358
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 2284
2266 // Allocate space for v8::Arguments implicit values. Must be initialized 2285 // Allocate space for v8::Arguments implicit values. Must be initialized
2267 // before calling any runtime function. 2286 // before calling any runtime function.
2268 __ subq(rsp, Immediate(kFastApiCallArguments * kPointerSize)); 2287 __ subq(rsp, Immediate(kFastApiCallArguments * kPointerSize));
2269 2288
2270 // Check that the maps haven't changed and find a Holder as a side effect. 2289 // Check that the maps haven't changed and find a Holder as a side effect.
2271 CheckPrototypes(Handle<JSObject>::cast(object), rdx, holder, rbx, rax, rdi, 2290 CheckPrototypes(Handle<JSObject>::cast(object), rdx, holder, rbx, rax, rdi,
2272 name, depth, &miss); 2291 name, depth, &miss);
2273 2292
2274 // Move the return address on top of the stack. 2293 // Move the return address on top of the stack.
2275 __ movq(rax, Operand(rsp, 4 * kPointerSize)); 2294 __ movq(rax, Operand(rsp, kFastApiCallArguments * kPointerSize));
2276 __ movq(Operand(rsp, 0 * kPointerSize), rax); 2295 __ movq(Operand(rsp, 0 * kPointerSize), rax);
2277 2296
2278 GenerateFastApiCall(masm(), optimization, argc); 2297 GenerateFastApiCall(masm(), optimization, argc);
2279 2298
2280 __ bind(&miss); 2299 __ bind(&miss);
2281 __ addq(rsp, Immediate(kFastApiCallArguments * kPointerSize)); 2300 __ addq(rsp, Immediate(kFastApiCallArguments * kPointerSize));
2282 2301
2283 __ bind(&miss_before_stack_reserved); 2302 __ bind(&miss_before_stack_reserved);
2284 GenerateMissBranch(); 2303 GenerateMissBranch();
2285 2304
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after
3593 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); 3612 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
3594 } 3613 }
3595 } 3614 }
3596 3615
3597 3616
3598 #undef __ 3617 #undef __
3599 3618
3600 } } // namespace v8::internal 3619 } } // namespace v8::internal
3601 3620
3602 #endif // V8_TARGET_ARCH_X64 3621 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698