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

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 223823002: Revert r20474 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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/builtins-ia32.cc ('k') | src/ia32/debug-ia32.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 2345 matching lines...) Expand 10 before | Expand all | Expand 10 after
2356 __ RecordWriteArray(ebx, edi, edx, kDontSaveFPRegs, 2356 __ RecordWriteArray(ebx, edi, edx, kDontSaveFPRegs,
2357 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); 2357 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
2358 __ pop(edx); 2358 __ pop(edx);
2359 __ pop(ebx); 2359 __ pop(ebx);
2360 __ pop(edi); 2360 __ pop(edi);
2361 2361
2362 __ bind(&done); 2362 __ bind(&done);
2363 } 2363 }
2364 2364
2365 2365
2366 static void GenericCallHelper(MacroAssembler* masm, 2366 void CallFunctionStub::Generate(MacroAssembler* masm) {
2367 const CallIC::State& state) { 2367 // ebx : feedback vector
2368 // edx : (only if ebx is not the megamorphic symbol) slot in feedback
2369 // vector (Smi)
2368 // edi : the function to call 2370 // edi : the function to call
2369 Isolate* isolate = masm->isolate(); 2371 Isolate* isolate = masm->isolate();
2370 Label slow, non_function, wrap, cont; 2372 Label slow, non_function, wrap, cont;
2371 2373
2372 if (state.IsGeneric()) { 2374 if (NeedsChecks()) {
2373 // Check that the function really is a JavaScript function. 2375 // Check that the function really is a JavaScript function.
2374 __ JumpIfSmi(edi, &non_function); 2376 __ JumpIfSmi(edi, &non_function);
2375 2377
2376 // Goto slow case if we do not have a function. 2378 // Goto slow case if we do not have a function.
2377 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); 2379 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx);
2378 __ j(not_equal, &slow); 2380 __ j(not_equal, &slow);
2381
2382 if (RecordCallTarget()) {
2383 GenerateRecordCallTarget(masm);
2384 // Type information was updated. Because we may call Array, which
2385 // expects either undefined or an AllocationSite in ebx we need
2386 // to set ebx to undefined.
2387 __ mov(ebx, Immediate(isolate->factory()->undefined_value()));
2388 }
2379 } 2389 }
2380 2390
2381 // Fast-case: Just invoke the function. 2391 // Fast-case: Just invoke the function.
2382 int argc = state.arg_count(); 2392 ParameterCount actual(argc_);
2383 ParameterCount actual(argc);
2384 2393
2385 if (state.CallAsMethod()) { 2394 if (CallAsMethod()) {
2386 if (state.IsGeneric()) { 2395 if (NeedsChecks()) {
2387 // Do not transform the receiver for strict mode functions. 2396 // Do not transform the receiver for strict mode functions.
2388 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); 2397 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
2389 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kStrictModeByteOffset), 2398 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kStrictModeByteOffset),
2390 1 << SharedFunctionInfo::kStrictModeBitWithinByte); 2399 1 << SharedFunctionInfo::kStrictModeBitWithinByte);
2391 __ j(not_equal, &cont); 2400 __ j(not_equal, &cont);
2392 2401
2393 // Do not transform the receiver for natives (shared already in ecx). 2402 // Do not transform the receiver for natives (shared already in ecx).
2394 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kNativeByteOffset), 2403 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kNativeByteOffset),
2395 1 << SharedFunctionInfo::kNativeBitWithinByte); 2404 1 << SharedFunctionInfo::kNativeBitWithinByte);
2396 __ j(not_equal, &cont); 2405 __ j(not_equal, &cont);
2397 } 2406 }
2398 2407
2399 if (state.IsSloppy()) { 2408 // Load the receiver from the stack.
2400 // Load the receiver from the stack. 2409 __ mov(eax, Operand(esp, (argc_ + 1) * kPointerSize));
2401 __ mov(eax, Operand(esp, (argc + 1) * kPointerSize));
2402 2410
2411 if (NeedsChecks()) {
2403 __ JumpIfSmi(eax, &wrap); 2412 __ JumpIfSmi(eax, &wrap);
2404 2413
2405 __ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, ecx); 2414 __ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, ecx);
2406 __ j(below, &wrap); 2415 __ j(below, &wrap);
2416 } else {
2417 __ jmp(&wrap);
2407 } 2418 }
2408 2419
2409 __ bind(&cont); 2420 __ bind(&cont);
2410 } 2421 }
2411 2422
2412 if (state.ArgumentsMustMatch()) { 2423 __ InvokeFunction(edi, actual, JUMP_FUNCTION, NullCallWrapper());
2413 __ InvokeFunction(edi, actual, actual, JUMP_FUNCTION, NullCallWrapper());
2414 } else {
2415 __ InvokeFunction(edi, actual, JUMP_FUNCTION, NullCallWrapper());
2416 }
2417 2424
2418 if (state.IsGeneric()) { 2425 if (NeedsChecks()) {
2419 // Slow-case: Non-function called. 2426 // Slow-case: Non-function called.
2420 __ bind(&slow); 2427 __ bind(&slow);
2428 if (RecordCallTarget()) {
2429 // If there is a call target cache, mark it megamorphic in the
2430 // non-function case. MegamorphicSentinel is an immortal immovable
2431 // object (megamorphic symbol) so no write barrier is needed.
2432 __ mov(FieldOperand(ebx, edx, times_half_pointer_size,
2433 FixedArray::kHeaderSize),
2434 Immediate(TypeFeedbackInfo::MegamorphicSentinel(isolate)));
2435 }
2421 // Check for function proxy. 2436 // Check for function proxy.
2422 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); 2437 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE);
2423 __ j(not_equal, &non_function); 2438 __ j(not_equal, &non_function);
2424 __ pop(ecx); 2439 __ pop(ecx);
2425 __ push(edi); // put proxy as additional argument under return address 2440 __ push(edi); // put proxy as additional argument under return address
2426 __ push(ecx); 2441 __ push(ecx);
2427 __ Move(eax, Immediate(argc + 1)); 2442 __ Move(eax, Immediate(argc_ + 1));
2428 __ Move(ebx, Immediate(0)); 2443 __ Move(ebx, Immediate(0));
2429 __ GetBuiltinEntry(edx, Builtins::CALL_FUNCTION_PROXY); 2444 __ GetBuiltinEntry(edx, Builtins::CALL_FUNCTION_PROXY);
2430 { 2445 {
2431 Handle<Code> adaptor = isolate->builtins()->ArgumentsAdaptorTrampoline(); 2446 Handle<Code> adaptor = isolate->builtins()->ArgumentsAdaptorTrampoline();
2432 __ jmp(adaptor, RelocInfo::CODE_TARGET); 2447 __ jmp(adaptor, RelocInfo::CODE_TARGET);
2433 } 2448 }
2434 2449
2435 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead 2450 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead
2436 // of the original receiver from the call site). 2451 // of the original receiver from the call site).
2437 __ bind(&non_function); 2452 __ bind(&non_function);
2438 __ mov(Operand(esp, (argc + 1) * kPointerSize), edi); 2453 __ mov(Operand(esp, (argc_ + 1) * kPointerSize), edi);
2439 __ Move(eax, Immediate(argc)); 2454 __ Move(eax, Immediate(argc_));
2440 __ Move(ebx, Immediate(0)); 2455 __ Move(ebx, Immediate(0));
2441 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); 2456 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION);
2442 Handle<Code> adaptor = isolate->builtins()->ArgumentsAdaptorTrampoline(); 2457 Handle<Code> adaptor = isolate->builtins()->ArgumentsAdaptorTrampoline();
2443 __ jmp(adaptor, RelocInfo::CODE_TARGET); 2458 __ jmp(adaptor, RelocInfo::CODE_TARGET);
2444 } 2459 }
2445 2460
2446 if (state.CallAsMethod() && state.IsSloppy()) { 2461 if (CallAsMethod()) {
2447 __ bind(&wrap); 2462 __ bind(&wrap);
2448
2449 if (!state.IsGeneric()) {
2450 // Do not transform the receiver for natives (shared already in ecx).
2451 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
2452 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kNativeByteOffset),
2453 1 << SharedFunctionInfo::kNativeBitWithinByte);
2454 __ j(not_equal, &cont);
2455 }
2456
2457 // Wrap the receiver and patch it back onto the stack. 2463 // Wrap the receiver and patch it back onto the stack.
2458 { FrameScope frame_scope(masm, StackFrame::INTERNAL); 2464 { FrameScope frame_scope(masm, StackFrame::INTERNAL);
2459 __ push(edi); 2465 __ push(edi);
2460 __ push(eax); 2466 __ push(eax);
2461 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); 2467 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION);
2462 __ pop(edi); 2468 __ pop(edi);
2463 } 2469 }
2464 __ mov(Operand(esp, (argc + 1) * kPointerSize), eax); 2470 __ mov(Operand(esp, (argc_ + 1) * kPointerSize), eax);
2465 __ jmp(&cont); 2471 __ jmp(&cont);
2466 } 2472 }
2467 } 2473 }
2468 2474
2469 2475
2470 void CallFunctionStub::Generate(MacroAssembler* masm) {
2471 // edi : the function to call
2472
2473 // GenericCallHelper expresses it's options in terms of CallIC::State.
2474 CallIC::CallType call_type = CallAsMethod() ?
2475 CallIC::METHOD : CallIC::FUNCTION;
2476
2477 if (NeedsChecks()) {
2478 GenericCallHelper(masm,
2479 CallIC::State::SlowCallState(
2480 argc_,
2481 call_type));
2482 } else {
2483 GenericCallHelper(masm,
2484 CallIC::State::MonomorphicCallState(
2485 argc_,
2486 call_type,
2487 CallIC::ARGUMENTS_COUNT_UNKNOWN,
2488 SLOPPY));
2489 }
2490 }
2491
2492
2493 void CallConstructStub::Generate(MacroAssembler* masm) { 2476 void CallConstructStub::Generate(MacroAssembler* masm) {
2494 // eax : number of arguments 2477 // eax : number of arguments
2495 // ebx : feedback vector 2478 // ebx : feedback vector
2496 // edx : (only if ebx is not the megamorphic symbol) slot in feedback 2479 // edx : (only if ebx is not the megamorphic symbol) slot in feedback
2497 // vector (Smi) 2480 // vector (Smi)
2498 // edi : constructor function 2481 // edi : constructor function
2499 Label slow, non_function_call; 2482 Label slow, non_function_call;
2500 2483
2501 // Check that function is not a smi. 2484 // Check that function is not a smi.
2502 __ JumpIfSmi(edi, &non_function_call); 2485 __ JumpIfSmi(edi, &non_function_call);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2551 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); 2534 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR);
2552 __ bind(&do_call); 2535 __ bind(&do_call);
2553 // Set expected number of arguments to zero (not changing eax). 2536 // Set expected number of arguments to zero (not changing eax).
2554 __ Move(ebx, Immediate(0)); 2537 __ Move(ebx, Immediate(0));
2555 Handle<Code> arguments_adaptor = 2538 Handle<Code> arguments_adaptor =
2556 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); 2539 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline();
2557 __ jmp(arguments_adaptor, RelocInfo::CODE_TARGET); 2540 __ jmp(arguments_adaptor, RelocInfo::CODE_TARGET);
2558 } 2541 }
2559 2542
2560 2543
2561 void CallICStub::GenerateMonomorphicCall(MacroAssembler* masm) {
2562 GenericCallHelper(masm,
2563 CallIC::State::MonomorphicCallState(
2564 state_.arg_count(),
2565 state_.call_type(),
2566 state_.argument_check(),
2567 state_.strict_mode()));
2568 }
2569
2570
2571 void CallICStub::GenerateSlowCall(MacroAssembler* masm) {
2572 GenericCallHelper(masm,
2573 CallIC::State::SlowCallState(
2574 state_.arg_count(),
2575 state_.call_type()));
2576 }
2577
2578
2579 void CallICStub::Generate(MacroAssembler* masm) {
2580 // edi - function
2581 // ebx - vector
2582 // edx - slot id
2583 Isolate* isolate = masm->isolate();
2584 Label extra_checks_or_miss, slow;
2585
2586 // The checks. First, does edi match the recorded monomorphic target?
2587 __ cmp(edi, FieldOperand(ebx, edx, times_half_pointer_size,
2588 FixedArray::kHeaderSize));
2589 __ j(not_equal, &extra_checks_or_miss);
2590
2591 GenerateMonomorphicCall(masm);
2592
2593 __ bind(&extra_checks_or_miss);
2594 if (IsGeneric()) {
2595 Label miss_uninit;
2596
2597 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size,
2598 FixedArray::kHeaderSize));
2599 __ cmp(ecx, Immediate(TypeFeedbackInfo::MegamorphicSentinel(isolate)));
2600 __ j(equal, &slow);
2601 __ cmp(ecx, Immediate(TypeFeedbackInfo::UninitializedSentinel(isolate)));
2602 __ j(equal, &miss_uninit);
2603 // If we get here, go from monomorphic to megamorphic, Don't bother missing,
2604 // just update.
2605 __ mov(FieldOperand(ebx, edx, times_half_pointer_size,
2606 FixedArray::kHeaderSize),
2607 Immediate(TypeFeedbackInfo::MegamorphicSentinel(isolate)));
2608 __ jmp(&slow);
2609
2610 __ bind(&miss_uninit);
2611 }
2612
2613 GenerateMiss(masm);
2614
2615 // the slow case
2616 __ bind(&slow);
2617 GenerateSlowCall(masm);
2618 }
2619
2620
2621 void CallICStub::GenerateMiss(MacroAssembler* masm) {
2622 // Get the receiver of the function from the stack; 1 ~ return address.
2623 __ mov(ecx, Operand(esp, (state_.arg_count() + 1) * kPointerSize));
2624
2625 {
2626 FrameScope scope(masm, StackFrame::INTERNAL);
2627
2628 // Push the receiver and the function and feedback info.
2629 __ push(ecx);
2630 __ push(edi);
2631 __ push(ebx);
2632 __ push(edx);
2633
2634 // Call the entry.
2635 ExternalReference miss = ExternalReference(IC_Utility(IC::kCallIC_Miss),
2636 masm->isolate());
2637 __ CallExternalReference(miss, 4);
2638
2639 // Move result to edi and exit the internal frame.
2640 __ mov(edi, eax);
2641 }
2642 }
2643
2644
2645 bool CEntryStub::NeedsImmovableCode() { 2544 bool CEntryStub::NeedsImmovableCode() {
2646 return false; 2545 return false;
2647 } 2546 }
2648 2547
2649 2548
2650 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { 2549 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) {
2651 CEntryStub::GenerateAheadOfTime(isolate); 2550 CEntryStub::GenerateAheadOfTime(isolate);
2652 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate); 2551 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate);
2653 StubFailureTrampolineStub::GenerateAheadOfTime(isolate); 2552 StubFailureTrampolineStub::GenerateAheadOfTime(isolate);
2654 // It is important that the store buffer overflow stubs are generated first. 2553 // It is important that the store buffer overflow stubs are generated first.
(...skipping 2808 matching lines...) Expand 10 before | Expand all | Expand 10 after
5463 Operand(ebp, 7 * kPointerSize), 5362 Operand(ebp, 7 * kPointerSize),
5464 NULL); 5363 NULL);
5465 } 5364 }
5466 5365
5467 5366
5468 #undef __ 5367 #undef __
5469 5368
5470 } } // namespace v8::internal 5369 } } // namespace v8::internal
5471 5370
5472 #endif // V8_TARGET_ARCH_IA32 5371 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/builtins-ia32.cc ('k') | src/ia32/debug-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698