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

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

Issue 24488006: Refactor PropertyCallbackInfo & FunctionCallbackInfo, part 3. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 7 years, 2 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/arm/stub-cache-arm.cc ('k') | src/x64/stub-cache-x64.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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 // -- esp[4] - esp[28] : FunctionCallbackInfo, incl. 465 // -- esp[4] - esp[28] : FunctionCallbackInfo, incl.
466 // : object passing the type check 466 // : object passing the type check
467 // (set by CheckPrototypes) 467 // (set by CheckPrototypes)
468 // -- esp[32] : last argument 468 // -- esp[32] : last argument
469 // -- ... 469 // -- ...
470 // -- esp[(argc + 7) * 4] : first argument 470 // -- esp[(argc + 7) * 4] : first argument
471 // -- esp[(argc + 8) * 4] : receiver 471 // -- esp[(argc + 8) * 4] : receiver
472 // ----------------------------------- 472 // -----------------------------------
473 473
474 typedef FunctionCallbackArguments FCA; 474 typedef FunctionCallbackArguments FCA;
475 const int kArgs = kFastApiCallArguments;
476 // Save calling context. 475 // Save calling context.
477 __ mov(Operand(esp, (kArgs + FCA::kContextSaveIndex) * kPointerSize), esi); 476 __ mov(Operand(esp, (1 + FCA::kContextSaveIndex) * kPointerSize), esi);
478 477
479 // Get the function and setup the context. 478 // Get the function and setup the context.
480 Handle<JSFunction> function = optimization.constant_function(); 479 Handle<JSFunction> function = optimization.constant_function();
481 __ LoadHeapObject(edi, function); 480 __ LoadHeapObject(edi, function);
482 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); 481 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
483 482
484 // Construct the FunctionCallbackInfo. 483 // Construct the FunctionCallbackInfo.
485 __ mov(Operand(esp, (kArgs + FCA::kCalleeIndex) * kPointerSize), edi); 484 __ mov(Operand(esp, (1 + FCA::kCalleeIndex) * kPointerSize), edi);
486 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); 485 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info();
487 Handle<Object> call_data(api_call_info->data(), masm->isolate()); 486 Handle<Object> call_data(api_call_info->data(), masm->isolate());
488 if (masm->isolate()->heap()->InNewSpace(*call_data)) { 487 if (masm->isolate()->heap()->InNewSpace(*call_data)) {
489 __ mov(ecx, api_call_info); 488 __ mov(ecx, api_call_info);
490 __ mov(ebx, FieldOperand(ecx, CallHandlerInfo::kDataOffset)); 489 __ mov(ebx, FieldOperand(ecx, CallHandlerInfo::kDataOffset));
491 __ mov(Operand(esp, (kArgs + FCA::kDataIndex) * kPointerSize), ebx); 490 __ mov(Operand(esp, (1 + FCA::kDataIndex) * kPointerSize), ebx);
492 } else { 491 } else {
493 __ mov(Operand(esp, (kArgs + FCA::kDataIndex) * kPointerSize), 492 __ mov(Operand(esp, (1 + FCA::kDataIndex) * kPointerSize),
494 Immediate(call_data)); 493 Immediate(call_data));
495 } 494 }
496 __ mov(Operand(esp, (kArgs + FCA::kIsolateIndex) * kPointerSize), 495 __ mov(Operand(esp, (1 + FCA::kIsolateIndex) * kPointerSize),
497 Immediate(reinterpret_cast<int>(masm->isolate()))); 496 Immediate(reinterpret_cast<int>(masm->isolate())));
498 __ mov(Operand(esp, (kArgs + FCA::kReturnValueOffset) * kPointerSize), 497 __ mov(Operand(esp, (1 + FCA::kReturnValueOffset) * kPointerSize),
499 masm->isolate()->factory()->undefined_value()); 498 masm->isolate()->factory()->undefined_value());
500 __ mov( 499 __ mov(Operand(esp, (1 + FCA::kReturnValueDefaultValueIndex) * kPointerSize),
501 Operand(esp, (kArgs + FCA::kReturnValueDefaultValueIndex) * kPointerSize), 500 masm->isolate()->factory()->undefined_value());
502 masm->isolate()->factory()->undefined_value());
503 501
504 // Prepare arguments. 502 // Prepare arguments.
505 STATIC_ASSERT(kArgs == 7); 503 STATIC_ASSERT(kFastApiCallArguments == 7);
506 __ lea(eax, Operand(esp, kArgs * kPointerSize)); 504 __ lea(eax, Operand(esp, 1 * kPointerSize));
507
508 505
509 // API function gets reference to the v8::Arguments. If CPU profiler 506 // API function gets reference to the v8::Arguments. If CPU profiler
510 // is enabled wrapper function will be called and we need to pass 507 // is enabled wrapper function will be called and we need to pass
511 // address of the callback as additional parameter, always allocate 508 // address of the callback as additional parameter, always allocate
512 // space for it. 509 // space for it.
513 const int kApiArgc = 1 + 1; 510 const int kApiArgc = 1 + 1;
514 511
515 // Allocate the v8::Arguments structure in the arguments' space since 512 // Allocate the v8::Arguments structure in the arguments' space since
516 // it's not controlled by GC. 513 // it's not controlled by GC.
517 const int kApiStackSpace = 4; 514 const int kApiStackSpace = 4;
518 515
519 // Function address is a foreign pointer outside V8's heap. 516 // Function address is a foreign pointer outside V8's heap.
520 Address function_address = v8::ToCData<Address>(api_call_info->callback()); 517 Address function_address = v8::ToCData<Address>(api_call_info->callback());
521 __ PrepareCallApiFunction(kApiArgc + kApiStackSpace); 518 __ PrepareCallApiFunction(kApiArgc + kApiStackSpace);
522 519
523 // v8::Arguments::implicit_args_. 520 // FunctionCallbackInfo::implicit_args_.
524 __ mov(ApiParameterOperand(2), eax); 521 __ mov(ApiParameterOperand(2), eax);
525 __ add(eax, Immediate(argc * kPointerSize)); 522 __ add(eax, Immediate((argc + kFastApiCallArguments - 1) * kPointerSize));
526 // v8::Arguments::values_. 523 // FunctionCallbackInfo::values_.
527 __ mov(ApiParameterOperand(3), eax); 524 __ mov(ApiParameterOperand(3), eax);
528 // v8::Arguments::length_. 525 // FunctionCallbackInfo::length_.
529 __ Set(ApiParameterOperand(4), Immediate(argc)); 526 __ Set(ApiParameterOperand(4), Immediate(argc));
530 // v8::Arguments::is_construct_call_. 527 // FunctionCallbackInfo::is_construct_call_.
531 __ Set(ApiParameterOperand(5), Immediate(0)); 528 __ Set(ApiParameterOperand(5), Immediate(0));
532 529
533 // v8::InvocationCallback's argument. 530 // v8::InvocationCallback's argument.
534 __ lea(eax, ApiParameterOperand(2)); 531 __ lea(eax, ApiParameterOperand(2));
535 __ mov(ApiParameterOperand(0), eax); 532 __ mov(ApiParameterOperand(0), eax);
536 533
537 Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback); 534 Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback);
538 535
539 Operand context_restore_operand( 536 Operand context_restore_operand(ebp,
540 ebp, (kArgs + 1 + FCA::kContextSaveIndex) * kPointerSize); 537 (2 + FCA::kContextSaveIndex) * kPointerSize);
541 Operand return_value_operand( 538 Operand return_value_operand(ebp,
542 ebp, (kArgs + 1 + FCA::kReturnValueOffset) * kPointerSize); 539 (2 + FCA::kReturnValueOffset) * kPointerSize);
543 __ CallApiFunctionAndReturn(function_address, 540 __ CallApiFunctionAndReturn(function_address,
544 thunk_address, 541 thunk_address,
545 ApiParameterOperand(1), 542 ApiParameterOperand(1),
546 argc + kArgs + 1, 543 argc + kFastApiCallArguments + 1,
547 return_value_operand, 544 return_value_operand,
548 restore_context ? 545 restore_context ?
549 &context_restore_operand : NULL); 546 &context_restore_operand : NULL);
550 } 547 }
551 548
552 549
553 // Generate call to api function. 550 // Generate call to api function.
554 static void GenerateFastApiCall(MacroAssembler* masm, 551 static void GenerateFastApiCall(MacroAssembler* masm,
555 const CallOptimization& optimization, 552 const CallOptimization& optimization,
556 Register receiver, 553 Register receiver,
557 Register scratch, 554 Register scratch,
558 int argc, 555 int argc,
559 Register* values) { 556 Register* values) {
560 ASSERT(optimization.is_simple_api_call()); 557 ASSERT(optimization.is_simple_api_call());
561 ASSERT(!receiver.is(scratch)); 558 ASSERT(!receiver.is(scratch));
562 559
563 const int stack_space = kFastApiCallArguments + argc + 1; 560 const int stack_space = kFastApiCallArguments + argc + 1;
564 const int kHolderIndex = kFastApiCallArguments + 561 const int kHolderIndex = FunctionCallbackArguments::kHolderIndex + 1;
565 FunctionCallbackArguments::kHolderIndex;
566 // Copy return value. 562 // Copy return value.
567 __ mov(scratch, Operand(esp, 0)); 563 __ mov(scratch, Operand(esp, 0));
568 // Assign stack space for the call arguments. 564 // Assign stack space for the call arguments.
569 __ sub(esp, Immediate(stack_space * kPointerSize)); 565 __ sub(esp, Immediate(stack_space * kPointerSize));
570 // Move the return address on top of the stack. 566 // Move the return address on top of the stack.
571 __ mov(Operand(esp, 0), scratch); 567 __ mov(Operand(esp, 0), scratch);
572 // Write holder to stack frame. 568 // Write holder to stack frame.
573 __ mov(Operand(esp, kHolderIndex * kPointerSize), receiver); 569 __ mov(Operand(esp, kHolderIndex * kPointerSize), receiver);
574 // Write receiver to stack frame. 570 // Write receiver to stack frame.
575 int index = stack_space; 571 int index = stack_space;
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 Register StubCompiler::CheckPrototypes(Handle<JSObject> object, 1156 Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
1161 Register object_reg, 1157 Register object_reg,
1162 Handle<JSObject> holder, 1158 Handle<JSObject> holder,
1163 Register holder_reg, 1159 Register holder_reg,
1164 Register scratch1, 1160 Register scratch1,
1165 Register scratch2, 1161 Register scratch2,
1166 Handle<Name> name, 1162 Handle<Name> name,
1167 int save_at_depth, 1163 int save_at_depth,
1168 Label* miss, 1164 Label* miss,
1169 PrototypeCheckType check) { 1165 PrototypeCheckType check) {
1170 const int kHolderIndex = kFastApiCallArguments + 1166 const int kHolderIndex = FunctionCallbackArguments::kHolderIndex + 1;
1171 FunctionCallbackArguments::kHolderIndex;
1172 // Make sure that the type feedback oracle harvests the receiver map. 1167 // Make sure that the type feedback oracle harvests the receiver map.
1173 // TODO(svenpanne) Remove this hack when all ICs are reworked. 1168 // TODO(svenpanne) Remove this hack when all ICs are reworked.
1174 __ mov(scratch1, Handle<Map>(object->map())); 1169 __ mov(scratch1, Handle<Map>(object->map()));
1175 1170
1176 Handle<JSObject> first = object; 1171 Handle<JSObject> first = object;
1177 // Make sure there's no overlap between holder and object registers. 1172 // Make sure there's no overlap between holder and object registers.
1178 ASSERT(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); 1173 ASSERT(!scratch1.is(object_reg) && !scratch1.is(holder_reg));
1179 ASSERT(!scratch2.is(object_reg) && !scratch2.is(holder_reg) 1174 ASSERT(!scratch2.is(object_reg) && !scratch2.is(holder_reg)
1180 && !scratch2.is(scratch1)); 1175 && !scratch2.is(scratch1));
1181 1176
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 } 1401 }
1407 1402
1408 1403
1409 void BaseLoadStubCompiler::GenerateLoadCallback( 1404 void BaseLoadStubCompiler::GenerateLoadCallback(
1410 Register reg, 1405 Register reg,
1411 Handle<ExecutableAccessorInfo> callback) { 1406 Handle<ExecutableAccessorInfo> callback) {
1412 // Insert additional parameters into the stack frame above return address. 1407 // Insert additional parameters into the stack frame above return address.
1413 ASSERT(!scratch3().is(reg)); 1408 ASSERT(!scratch3().is(reg));
1414 __ pop(scratch3()); // Get return address to place it below. 1409 __ pop(scratch3()); // Get return address to place it below.
1415 1410
1416 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 0); 1411 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0);
1417 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == -1); 1412 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1);
1418 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == -2); 1413 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2);
1419 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == -3); 1414 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3);
1420 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == -4); 1415 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 4);
1421 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == -5); 1416 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 5);
1422 __ push(receiver()); // receiver 1417 __ push(receiver()); // receiver
1423 __ mov(scratch2(), esp);
1424 ASSERT(!scratch2().is(reg));
1425 // Push data from ExecutableAccessorInfo. 1418 // Push data from ExecutableAccessorInfo.
1426 if (isolate()->heap()->InNewSpace(callback->data())) { 1419 if (isolate()->heap()->InNewSpace(callback->data())) {
1427 Register scratch = reg.is(scratch1()) ? receiver() : scratch1(); 1420 ASSERT(!scratch2().is(reg));
1428 __ mov(scratch, Immediate(callback)); 1421 __ mov(scratch2(), Immediate(callback));
1429 __ push(FieldOperand(scratch, ExecutableAccessorInfo::kDataOffset)); 1422 __ push(FieldOperand(scratch2(), ExecutableAccessorInfo::kDataOffset));
1430 } else { 1423 } else {
1431 __ push(Immediate(Handle<Object>(callback->data(), isolate()))); 1424 __ push(Immediate(Handle<Object>(callback->data(), isolate())));
1432 } 1425 }
1433 __ push(Immediate(isolate()->factory()->undefined_value())); // ReturnValue 1426 __ push(Immediate(isolate()->factory()->undefined_value())); // ReturnValue
1434 // ReturnValue default value 1427 // ReturnValue default value
1435 __ push(Immediate(isolate()->factory()->undefined_value())); 1428 __ push(Immediate(isolate()->factory()->undefined_value()));
1436 __ push(Immediate(reinterpret_cast<int>(isolate()))); 1429 __ push(Immediate(reinterpret_cast<int>(isolate())));
1437 __ push(reg); // holder 1430 __ push(reg); // holder
1438 1431
1439 // Save a pointer to where we pushed the arguments pointer. This will be 1432 // Save a pointer to where we pushed the arguments. This will be
1440 // passed as the const ExecutableAccessorInfo& to the C++ callback. 1433 // passed as the const PropertyAccessorInfo& to the C++ callback.
1441 __ push(scratch2()); 1434 __ push(esp);
1442 1435
1443 __ push(name()); // name 1436 __ push(name()); // name
1444 __ mov(ebx, esp); // esp points to reference to name (handler). 1437 __ mov(ebx, esp); // esp points to reference to name (handler).
1445 1438
1446 __ push(scratch3()); // Restore return address. 1439 __ push(scratch3()); // Restore return address.
1447 1440
1448 // array for v8::Arguments::values_, handler for name and pointer 1441 // array for v8::Arguments::values_, handler for name and pointer
1449 // to the values (it considered as smi in GC). 1442 // to the values (it considered as smi in GC).
1450 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 2; 1443 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 2;
1451 // Allocate space for opional callback address parameter in case 1444 // Allocate space for opional callback address parameter in case
(...skipping 1826 matching lines...) Expand 10 before | Expand all | Expand 10 after
3278 // ----------------------------------- 3271 // -----------------------------------
3279 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); 3272 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric);
3280 } 3273 }
3281 3274
3282 3275
3283 #undef __ 3276 #undef __
3284 3277
3285 } } // namespace v8::internal 3278 } } // namespace v8::internal
3286 3279
3287 #endif // V8_TARGET_ARCH_IA32 3280 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698