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

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

Issue 24196002: revert 16744 for breaking build (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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/x64/code-stubs-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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 // ----------------------------------- 451 // -----------------------------------
452 __ pop(scratch); 452 __ pop(scratch);
453 __ add(esp, Immediate(kPointerSize * kFastApiCallArguments)); 453 __ add(esp, Immediate(kPointerSize * kFastApiCallArguments));
454 __ push(scratch); 454 __ push(scratch);
455 } 455 }
456 456
457 457
458 // Generates call to API function. 458 // Generates call to API function.
459 static void GenerateFastApiCall(MacroAssembler* masm, 459 static void GenerateFastApiCall(MacroAssembler* masm,
460 const CallOptimization& optimization, 460 const CallOptimization& optimization,
461 int argc, 461 int argc) {
462 bool restore_context) {
463 // ----------- S t a t e ------------- 462 // ----------- S t a t e -------------
464 // -- esp[0] : return address 463 // -- esp[0] : return address
465 // -- esp[4] : context 464 // -- esp[4] : object passing the type check
466 // -- esp[8] : object passing the type check
467 // (last fast api call extra argument, 465 // (last fast api call extra argument,
468 // set by CheckPrototypes) 466 // set by CheckPrototypes)
469 // -- esp[12] : api function 467 // -- esp[8] : api function
470 // (first fast api call extra argument) 468 // (first fast api call extra argument)
471 // -- esp[16] : api call data 469 // -- esp[12] : api call data
472 // -- esp[20] : isolate 470 // -- esp[16] : isolate
473 // -- esp[24] : ReturnValue default value 471 // -- esp[20] : ReturnValue default value
474 // -- esp[28] : ReturnValue 472 // -- esp[24] : ReturnValue
475 // -- esp[32] : last argument 473 // -- esp[28] : last argument
476 // -- ... 474 // -- ...
477 // -- esp[(argc + 7) * 4] : first argument 475 // -- esp[(argc + 6) * 4] : first argument
478 // -- esp[(argc + 8) * 4] : receiver 476 // -- esp[(argc + 7) * 4] : receiver
479 // ----------------------------------- 477 // -----------------------------------
480
481 // Save calling context.
482 __ mov(Operand(esp, kPointerSize), esi);
483
484 // Get the function and setup the context. 478 // Get the function and setup the context.
485 Handle<JSFunction> function = optimization.constant_function(); 479 Handle<JSFunction> function = optimization.constant_function();
486 __ LoadHeapObject(edi, function); 480 __ LoadHeapObject(edi, function);
487 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); 481 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
488 482
489 // Pass the additional arguments. 483 // Pass the additional arguments.
490 __ mov(Operand(esp, 3 * kPointerSize), edi); 484 __ mov(Operand(esp, 2 * kPointerSize), edi);
491 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); 485 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info();
492 Handle<Object> call_data(api_call_info->data(), masm->isolate()); 486 Handle<Object> call_data(api_call_info->data(), masm->isolate());
493 if (masm->isolate()->heap()->InNewSpace(*call_data)) { 487 if (masm->isolate()->heap()->InNewSpace(*call_data)) {
494 __ mov(ecx, api_call_info); 488 __ mov(ecx, api_call_info);
495 __ mov(ebx, FieldOperand(ecx, CallHandlerInfo::kDataOffset)); 489 __ mov(ebx, FieldOperand(ecx, CallHandlerInfo::kDataOffset));
496 __ mov(Operand(esp, 4 * kPointerSize), ebx); 490 __ mov(Operand(esp, 3 * kPointerSize), ebx);
497 } else { 491 } else {
498 __ mov(Operand(esp, 4 * kPointerSize), Immediate(call_data)); 492 __ mov(Operand(esp, 3 * kPointerSize), Immediate(call_data));
499 } 493 }
494 __ mov(Operand(esp, 4 * kPointerSize),
495 Immediate(reinterpret_cast<int>(masm->isolate())));
500 __ mov(Operand(esp, 5 * kPointerSize), 496 __ mov(Operand(esp, 5 * kPointerSize),
501 Immediate(reinterpret_cast<int>(masm->isolate()))); 497 masm->isolate()->factory()->undefined_value());
502 __ mov(Operand(esp, 6 * kPointerSize), 498 __ mov(Operand(esp, 6 * kPointerSize),
503 masm->isolate()->factory()->undefined_value()); 499 masm->isolate()->factory()->undefined_value());
504 __ mov(Operand(esp, 7 * kPointerSize),
505 masm->isolate()->factory()->undefined_value());
506 500
507 // Prepare arguments. 501 // Prepare arguments.
508 STATIC_ASSERT(kFastApiCallArguments == 7); 502 STATIC_ASSERT(kFastApiCallArguments == 6);
509 __ lea(eax, Operand(esp, kFastApiCallArguments * kPointerSize)); 503 __ lea(eax, Operand(esp, kFastApiCallArguments * kPointerSize));
510 504
511 505
512 // API function gets reference to the v8::Arguments. If CPU profiler 506 // API function gets reference to the v8::Arguments. If CPU profiler
513 // 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
514 // address of the callback as additional parameter, always allocate 508 // address of the callback as additional parameter, always allocate
515 // space for it. 509 // space for it.
516 const int kApiArgc = 1 + 1; 510 const int kApiArgc = 1 + 1;
517 511
518 // Allocate the v8::Arguments structure in the arguments' space since 512 // Allocate the v8::Arguments structure in the arguments' space since
(...skipping 13 matching lines...) Expand all
532 __ Set(ApiParameterOperand(4), Immediate(argc)); 526 __ Set(ApiParameterOperand(4), Immediate(argc));
533 // v8::Arguments::is_construct_call_. 527 // v8::Arguments::is_construct_call_.
534 __ Set(ApiParameterOperand(5), Immediate(0)); 528 __ Set(ApiParameterOperand(5), Immediate(0));
535 529
536 // v8::InvocationCallback's argument. 530 // v8::InvocationCallback's argument.
537 __ lea(eax, ApiParameterOperand(2)); 531 __ lea(eax, ApiParameterOperand(2));
538 __ mov(ApiParameterOperand(0), eax); 532 __ mov(ApiParameterOperand(0), eax);
539 533
540 Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback); 534 Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback);
541 535
542 Operand context_restore_operand(ebp, 2 * kPointerSize);
543 Operand return_value_operand(
544 ebp, (kFastApiCallArguments + 1) * kPointerSize);
545 __ CallApiFunctionAndReturn(function_address, 536 __ CallApiFunctionAndReturn(function_address,
546 thunk_address, 537 thunk_address,
547 ApiParameterOperand(1), 538 ApiParameterOperand(1),
548 argc + kFastApiCallArguments + 1, 539 argc + kFastApiCallArguments + 1,
549 return_value_operand, 540 kFastApiCallArguments + 1);
550 restore_context ?
551 &context_restore_operand : NULL);
552 } 541 }
553 542
554 543
555 // Generate call to api function. 544 // Generate call to api function.
556 static void GenerateFastApiCall(MacroAssembler* masm, 545 static void GenerateFastApiCall(MacroAssembler* masm,
557 const CallOptimization& optimization, 546 const CallOptimization& optimization,
558 Register receiver, 547 Register receiver,
559 Register scratch, 548 Register scratch,
560 int argc, 549 int argc,
561 Register* values) { 550 Register* values) {
562 ASSERT(optimization.is_simple_api_call()); 551 ASSERT(optimization.is_simple_api_call());
563 ASSERT(!receiver.is(scratch)); 552 ASSERT(!receiver.is(scratch));
564 553
565 const int stack_space = kFastApiCallArguments + argc + 1; 554 const int stack_space = kFastApiCallArguments + argc + 1;
566 const int kHolderIndex = kFastApiCallArguments +
567 FunctionCallbackArguments::kHolderIndex;
568 // Copy return value. 555 // Copy return value.
569 __ mov(scratch, Operand(esp, 0)); 556 __ mov(scratch, Operand(esp, 0));
570 // Assign stack space for the call arguments. 557 // Assign stack space for the call arguments.
571 __ sub(esp, Immediate(stack_space * kPointerSize)); 558 __ sub(esp, Immediate(stack_space * kPointerSize));
572 // Move the return address on top of the stack. 559 // Move the return address on top of the stack.
573 __ mov(Operand(esp, 0), scratch); 560 __ mov(Operand(esp, 0), scratch);
574 // Write holder to stack frame. 561 // Write holder to stack frame.
575 __ mov(Operand(esp, kHolderIndex * kPointerSize), receiver); 562 __ mov(Operand(esp, 1 * kPointerSize), receiver);
576 // Write receiver to stack frame. 563 // Write receiver to stack frame.
577 int index = stack_space; 564 int index = stack_space;
578 __ mov(Operand(esp, index-- * kPointerSize), receiver); 565 __ mov(Operand(esp, index-- * kPointerSize), receiver);
579 // Write the arguments to stack frame. 566 // Write the arguments to stack frame.
580 for (int i = 0; i < argc; i++) { 567 for (int i = 0; i < argc; i++) {
581 ASSERT(!receiver.is(values[i])); 568 ASSERT(!receiver.is(values[i]));
582 ASSERT(!scratch.is(values[i])); 569 ASSERT(!scratch.is(values[i]));
583 __ mov(Operand(esp, index-- * kPointerSize), values[i]); 570 __ mov(Operand(esp, index-- * kPointerSize), values[i]);
584 } 571 }
585 572
586 GenerateFastApiCall(masm, optimization, argc, true); 573 GenerateFastApiCall(masm, optimization, argc);
587 } 574 }
588 575
589 576
590 class CallInterceptorCompiler BASE_EMBEDDED { 577 class CallInterceptorCompiler BASE_EMBEDDED {
591 public: 578 public:
592 CallInterceptorCompiler(StubCompiler* stub_compiler, 579 CallInterceptorCompiler(StubCompiler* stub_compiler,
593 const ParameterCount& arguments, 580 const ParameterCount& arguments,
594 Register name, 581 Register name,
595 Code::ExtraICState extra_state) 582 Code::ExtraICState extra_state)
596 : stub_compiler_(stub_compiler), 583 : stub_compiler_(stub_compiler),
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 } else { 677 } else {
691 // CheckPrototypes has a side effect of fetching a 'holder' 678 // CheckPrototypes has a side effect of fetching a 'holder'
692 // for API (object which is instanceof for the signature). It's 679 // for API (object which is instanceof for the signature). It's
693 // safe to omit it here, as if present, it should be fetched 680 // safe to omit it here, as if present, it should be fetched
694 // by the previous CheckPrototypes. 681 // by the previous CheckPrototypes.
695 ASSERT(depth2 == kInvalidProtoDepth); 682 ASSERT(depth2 == kInvalidProtoDepth);
696 } 683 }
697 684
698 // Invoke function. 685 // Invoke function.
699 if (can_do_fast_api_call) { 686 if (can_do_fast_api_call) {
700 GenerateFastApiCall(masm, optimization, arguments_.immediate(), false); 687 GenerateFastApiCall(masm, optimization, arguments_.immediate());
701 } else { 688 } else {
702 CallKind call_kind = CallICBase::Contextual::decode(extra_state_) 689 CallKind call_kind = CallICBase::Contextual::decode(extra_state_)
703 ? CALL_AS_FUNCTION 690 ? CALL_AS_FUNCTION
704 : CALL_AS_METHOD; 691 : CALL_AS_METHOD;
705 Handle<JSFunction> function = optimization.constant_function(); 692 Handle<JSFunction> function = optimization.constant_function();
706 ParameterCount expected(function); 693 ParameterCount expected(function);
707 __ InvokeFunction(function, expected, arguments_, 694 __ InvokeFunction(function, expected, arguments_,
708 JUMP_FUNCTION, NullCallWrapper(), call_kind); 695 JUMP_FUNCTION, NullCallWrapper(), call_kind);
709 } 696 }
710 697
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 Register StubCompiler::CheckPrototypes(Handle<JSObject> object, 1149 Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
1163 Register object_reg, 1150 Register object_reg,
1164 Handle<JSObject> holder, 1151 Handle<JSObject> holder,
1165 Register holder_reg, 1152 Register holder_reg,
1166 Register scratch1, 1153 Register scratch1,
1167 Register scratch2, 1154 Register scratch2,
1168 Handle<Name> name, 1155 Handle<Name> name,
1169 int save_at_depth, 1156 int save_at_depth,
1170 Label* miss, 1157 Label* miss,
1171 PrototypeCheckType check) { 1158 PrototypeCheckType check) {
1172 const int kHolderIndex = kFastApiCallArguments +
1173 FunctionCallbackArguments::kHolderIndex;
1174 // Make sure that the type feedback oracle harvests the receiver map. 1159 // Make sure that the type feedback oracle harvests the receiver map.
1175 // TODO(svenpanne) Remove this hack when all ICs are reworked. 1160 // TODO(svenpanne) Remove this hack when all ICs are reworked.
1176 __ mov(scratch1, Handle<Map>(object->map())); 1161 __ mov(scratch1, Handle<Map>(object->map()));
1177 1162
1178 Handle<JSObject> first = object; 1163 Handle<JSObject> first = object;
1179 // Make sure there's no overlap between holder and object registers. 1164 // Make sure there's no overlap between holder and object registers.
1180 ASSERT(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); 1165 ASSERT(!scratch1.is(object_reg) && !scratch1.is(holder_reg));
1181 ASSERT(!scratch2.is(object_reg) && !scratch2.is(holder_reg) 1166 ASSERT(!scratch2.is(object_reg) && !scratch2.is(holder_reg)
1182 && !scratch2.is(scratch1)); 1167 && !scratch2.is(scratch1));
1183 1168
1184 // Keep track of the current object in register reg. 1169 // Keep track of the current object in register reg.
1185 Register reg = object_reg; 1170 Register reg = object_reg;
1186 Handle<JSObject> current = object; 1171 Handle<JSObject> current = object;
1187 int depth = 0; 1172 int depth = 0;
1188 1173
1189 if (save_at_depth == depth) { 1174 if (save_at_depth == depth) {
1190 __ mov(Operand(esp, kHolderIndex * kPointerSize), reg); 1175 __ mov(Operand(esp, kPointerSize), reg);
1191 } 1176 }
1192 1177
1193 // Traverse the prototype chain and check the maps in the prototype chain for 1178 // Traverse the prototype chain and check the maps in the prototype chain for
1194 // fast and global objects or do negative lookup for normal objects. 1179 // fast and global objects or do negative lookup for normal objects.
1195 while (!current.is_identical_to(holder)) { 1180 while (!current.is_identical_to(holder)) {
1196 ++depth; 1181 ++depth;
1197 1182
1198 // Only global objects and objects that do not require access 1183 // Only global objects and objects that do not require access
1199 // checks are allowed in stubs. 1184 // checks are allowed in stubs.
1200 ASSERT(current->IsJSGlobalProxy() || !current->IsAccessCheckNeeded()); 1185 ASSERT(current->IsJSGlobalProxy() || !current->IsAccessCheckNeeded());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 // The prototype is in new space; we cannot store a reference to it 1226 // The prototype is in new space; we cannot store a reference to it
1242 // in the code. Load it from the map. 1227 // in the code. Load it from the map.
1243 __ mov(reg, FieldOperand(scratch1, Map::kPrototypeOffset)); 1228 __ mov(reg, FieldOperand(scratch1, Map::kPrototypeOffset));
1244 } else { 1229 } else {
1245 // The prototype is in old space; load it directly. 1230 // The prototype is in old space; load it directly.
1246 __ mov(reg, prototype); 1231 __ mov(reg, prototype);
1247 } 1232 }
1248 } 1233 }
1249 1234
1250 if (save_at_depth == depth) { 1235 if (save_at_depth == depth) {
1251 __ mov(Operand(esp, kHolderIndex * kPointerSize), reg); 1236 __ mov(Operand(esp, kPointerSize), reg);
1252 } 1237 }
1253 1238
1254 // Go to the next object in the prototype chain. 1239 // Go to the next object in the prototype chain.
1255 current = prototype; 1240 current = prototype;
1256 } 1241 }
1257 ASSERT(current.is_identical_to(holder)); 1242 ASSERT(current.is_identical_to(holder));
1258 1243
1259 // Log the check depth. 1244 // Log the check depth.
1260 LOG(isolate(), IntEvent("check-maps-depth", depth + 1)); 1245 LOG(isolate(), IntEvent("check-maps-depth", depth + 1));
1261 1246
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 // already generated). Do not allow the assembler to perform a 1449 // already generated). Do not allow the assembler to perform a
1465 // garbage collection but instead return the allocation failure 1450 // garbage collection but instead return the allocation failure
1466 // object. 1451 // object.
1467 1452
1468 Address thunk_address = FUNCTION_ADDR(&InvokeAccessorGetterCallback); 1453 Address thunk_address = FUNCTION_ADDR(&InvokeAccessorGetterCallback);
1469 1454
1470 __ CallApiFunctionAndReturn(getter_address, 1455 __ CallApiFunctionAndReturn(getter_address,
1471 thunk_address, 1456 thunk_address,
1472 ApiParameterOperand(2), 1457 ApiParameterOperand(2),
1473 kStackSpace, 1458 kStackSpace,
1474 Operand(ebp, 7 * kPointerSize), 1459 7);
1475 NULL);
1476 } 1460 }
1477 1461
1478 1462
1479 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<Object> value) { 1463 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<Object> value) {
1480 // Return the constant value. 1464 // Return the constant value.
1481 __ LoadObject(eax, value); 1465 __ LoadObject(eax, value);
1482 __ ret(0); 1466 __ ret(0);
1483 } 1467 }
1484 1468
1485 1469
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2628 // Check that the maps haven't changed and find a Holder as a side effect. 2612 // Check that the maps haven't changed and find a Holder as a side effect.
2629 CheckPrototypes(Handle<JSObject>::cast(object), edx, holder, ebx, eax, edi, 2613 CheckPrototypes(Handle<JSObject>::cast(object), edx, holder, ebx, eax, edi,
2630 name, depth, &miss); 2614 name, depth, &miss);
2631 2615
2632 // Move the return address on top of the stack. 2616 // Move the return address on top of the stack.
2633 __ mov(eax, Operand(esp, kFastApiCallArguments * kPointerSize)); 2617 __ mov(eax, Operand(esp, kFastApiCallArguments * kPointerSize));
2634 __ mov(Operand(esp, 0 * kPointerSize), eax); 2618 __ mov(Operand(esp, 0 * kPointerSize), eax);
2635 2619
2636 // esp[2 * kPointerSize] is uninitialized, esp[3 * kPointerSize] contains 2620 // esp[2 * kPointerSize] is uninitialized, esp[3 * kPointerSize] contains
2637 // duplicate of return address and will be overwritten. 2621 // duplicate of return address and will be overwritten.
2638 GenerateFastApiCall(masm(), optimization, argc, false); 2622 GenerateFastApiCall(masm(), optimization, argc);
2639 2623
2640 __ bind(&miss); 2624 __ bind(&miss);
2641 __ add(esp, Immediate(kFastApiCallArguments * kPointerSize)); 2625 __ add(esp, Immediate(kFastApiCallArguments * kPointerSize));
2642 2626
2643 __ bind(&miss_before_stack_reserved); 2627 __ bind(&miss_before_stack_reserved);
2644 GenerateMissBranch(); 2628 GenerateMissBranch();
2645 2629
2646 // Return the generated code. 2630 // Return the generated code.
2647 return GetCode(function); 2631 return GetCode(function);
2648 } 2632 }
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
3280 // ----------------------------------- 3264 // -----------------------------------
3281 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); 3265 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric);
3282 } 3266 }
3283 3267
3284 3268
3285 #undef __ 3269 #undef __
3286 3270
3287 } } // namespace v8::internal 3271 } } // namespace v8::internal
3288 3272
3289 #endif // V8_TARGET_ARCH_IA32 3273 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698