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

Side by Side Diff: src/ia32/macro-assembler-ia32.cc

Issue 136403005: Remove CALL_AS_FUNCTION and CALL_AS_METHOD. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Don't store/restore ecx/rcx/r5 given that it doesn't contain callkind anymore Created 6 years, 11 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.h ('k') | src/ia32/stub-cache-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 2437 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 2448
2449 2449
2450 void MacroAssembler::JumpToExternalReference(const ExternalReference& ext) { 2450 void MacroAssembler::JumpToExternalReference(const ExternalReference& ext) {
2451 // Set the entry point and jump to the C entry runtime stub. 2451 // Set the entry point and jump to the C entry runtime stub.
2452 mov(ebx, Immediate(ext)); 2452 mov(ebx, Immediate(ext));
2453 CEntryStub ces(1); 2453 CEntryStub ces(1);
2454 jmp(ces.GetCode(isolate()), RelocInfo::CODE_TARGET); 2454 jmp(ces.GetCode(isolate()), RelocInfo::CODE_TARGET);
2455 } 2455 }
2456 2456
2457 2457
2458 void MacroAssembler::SetCallKind(Register dst, CallKind call_kind) {
2459 // This macro takes the dst register to make the code more readable
2460 // at the call sites. However, the dst register has to be ecx to
2461 // follow the calling convention which requires the call type to be
2462 // in ecx.
2463 ASSERT(dst.is(ecx));
2464 if (call_kind == CALL_AS_FUNCTION) {
2465 // Set to some non-zero smi by updating the least significant
2466 // byte.
2467 mov_b(dst, 1 << kSmiTagSize);
2468 } else {
2469 // Set to smi zero by clearing the register.
2470 xor_(dst, dst);
2471 }
2472 }
2473
2474
2475 void MacroAssembler::InvokePrologue(const ParameterCount& expected, 2458 void MacroAssembler::InvokePrologue(const ParameterCount& expected,
2476 const ParameterCount& actual, 2459 const ParameterCount& actual,
2477 Handle<Code> code_constant, 2460 Handle<Code> code_constant,
2478 const Operand& code_operand, 2461 const Operand& code_operand,
2479 Label* done, 2462 Label* done,
2480 bool* definitely_mismatches, 2463 bool* definitely_mismatches,
2481 InvokeFlag flag, 2464 InvokeFlag flag,
2482 Label::Distance done_near, 2465 Label::Distance done_near,
2483 const CallWrapper& call_wrapper, 2466 const CallWrapper& call_wrapper) {
2484 CallKind call_kind) {
2485 bool definitely_matches = false; 2467 bool definitely_matches = false;
2486 *definitely_mismatches = false; 2468 *definitely_mismatches = false;
2487 Label invoke; 2469 Label invoke;
2488 if (expected.is_immediate()) { 2470 if (expected.is_immediate()) {
2489 ASSERT(actual.is_immediate()); 2471 ASSERT(actual.is_immediate());
2490 if (expected.immediate() == actual.immediate()) { 2472 if (expected.immediate() == actual.immediate()) {
2491 definitely_matches = true; 2473 definitely_matches = true;
2492 } else { 2474 } else {
2493 mov(eax, actual.immediate()); 2475 mov(eax, actual.immediate());
2494 const int sentinel = SharedFunctionInfo::kDontAdaptArgumentsSentinel; 2476 const int sentinel = SharedFunctionInfo::kDontAdaptArgumentsSentinel;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2527 isolate()->builtins()->ArgumentsAdaptorTrampoline(); 2509 isolate()->builtins()->ArgumentsAdaptorTrampoline();
2528 if (!code_constant.is_null()) { 2510 if (!code_constant.is_null()) {
2529 mov(edx, Immediate(code_constant)); 2511 mov(edx, Immediate(code_constant));
2530 add(edx, Immediate(Code::kHeaderSize - kHeapObjectTag)); 2512 add(edx, Immediate(Code::kHeaderSize - kHeapObjectTag));
2531 } else if (!code_operand.is_reg(edx)) { 2513 } else if (!code_operand.is_reg(edx)) {
2532 mov(edx, code_operand); 2514 mov(edx, code_operand);
2533 } 2515 }
2534 2516
2535 if (flag == CALL_FUNCTION) { 2517 if (flag == CALL_FUNCTION) {
2536 call_wrapper.BeforeCall(CallSize(adaptor, RelocInfo::CODE_TARGET)); 2518 call_wrapper.BeforeCall(CallSize(adaptor, RelocInfo::CODE_TARGET));
2537 SetCallKind(ecx, call_kind);
2538 call(adaptor, RelocInfo::CODE_TARGET); 2519 call(adaptor, RelocInfo::CODE_TARGET);
2539 call_wrapper.AfterCall(); 2520 call_wrapper.AfterCall();
2540 if (!*definitely_mismatches) { 2521 if (!*definitely_mismatches) {
2541 jmp(done, done_near); 2522 jmp(done, done_near);
2542 } 2523 }
2543 } else { 2524 } else {
2544 SetCallKind(ecx, call_kind);
2545 jmp(adaptor, RelocInfo::CODE_TARGET); 2525 jmp(adaptor, RelocInfo::CODE_TARGET);
2546 } 2526 }
2547 bind(&invoke); 2527 bind(&invoke);
2548 } 2528 }
2549 } 2529 }
2550 2530
2551 2531
2552 void MacroAssembler::InvokeCode(const Operand& code, 2532 void MacroAssembler::InvokeCode(const Operand& code,
2553 const ParameterCount& expected, 2533 const ParameterCount& expected,
2554 const ParameterCount& actual, 2534 const ParameterCount& actual,
2555 InvokeFlag flag, 2535 InvokeFlag flag,
2556 const CallWrapper& call_wrapper, 2536 const CallWrapper& call_wrapper) {
2557 CallKind call_kind) {
2558 // You can't call a function without a valid frame. 2537 // You can't call a function without a valid frame.
2559 ASSERT(flag == JUMP_FUNCTION || has_frame()); 2538 ASSERT(flag == JUMP_FUNCTION || has_frame());
2560 2539
2561 Label done; 2540 Label done;
2562 bool definitely_mismatches = false; 2541 bool definitely_mismatches = false;
2563 InvokePrologue(expected, actual, Handle<Code>::null(), code, 2542 InvokePrologue(expected, actual, Handle<Code>::null(), code,
2564 &done, &definitely_mismatches, flag, Label::kNear, 2543 &done, &definitely_mismatches, flag, Label::kNear,
2565 call_wrapper, call_kind); 2544 call_wrapper);
2566 if (!definitely_mismatches) { 2545 if (!definitely_mismatches) {
2567 if (flag == CALL_FUNCTION) { 2546 if (flag == CALL_FUNCTION) {
2568 call_wrapper.BeforeCall(CallSize(code)); 2547 call_wrapper.BeforeCall(CallSize(code));
2569 SetCallKind(ecx, call_kind);
2570 call(code); 2548 call(code);
2571 call_wrapper.AfterCall(); 2549 call_wrapper.AfterCall();
2572 } else { 2550 } else {
2573 ASSERT(flag == JUMP_FUNCTION); 2551 ASSERT(flag == JUMP_FUNCTION);
2574 SetCallKind(ecx, call_kind);
2575 jmp(code); 2552 jmp(code);
2576 } 2553 }
2577 bind(&done); 2554 bind(&done);
2578 } 2555 }
2579 } 2556 }
2580 2557
2581 2558
2582 void MacroAssembler::InvokeCode(Handle<Code> code, 2559 void MacroAssembler::InvokeCode(Handle<Code> code,
2583 const ParameterCount& expected, 2560 const ParameterCount& expected,
2584 const ParameterCount& actual, 2561 const ParameterCount& actual,
2585 RelocInfo::Mode rmode, 2562 RelocInfo::Mode rmode,
2586 InvokeFlag flag, 2563 InvokeFlag flag,
2587 const CallWrapper& call_wrapper, 2564 const CallWrapper& call_wrapper) {
2588 CallKind call_kind) {
2589 // You can't call a function without a valid frame. 2565 // You can't call a function without a valid frame.
2590 ASSERT(flag == JUMP_FUNCTION || has_frame()); 2566 ASSERT(flag == JUMP_FUNCTION || has_frame());
2591 2567
2592 Label done; 2568 Label done;
2593 Operand dummy(eax, 0); 2569 Operand dummy(eax, 0);
2594 bool definitely_mismatches = false; 2570 bool definitely_mismatches = false;
2595 InvokePrologue(expected, actual, code, dummy, &done, &definitely_mismatches, 2571 InvokePrologue(expected, actual, code, dummy, &done, &definitely_mismatches,
2596 flag, Label::kNear, call_wrapper, call_kind); 2572 flag, Label::kNear, call_wrapper);
2597 if (!definitely_mismatches) { 2573 if (!definitely_mismatches) {
2598 if (flag == CALL_FUNCTION) { 2574 if (flag == CALL_FUNCTION) {
2599 call_wrapper.BeforeCall(CallSize(code, rmode)); 2575 call_wrapper.BeforeCall(CallSize(code, rmode));
2600 SetCallKind(ecx, call_kind);
2601 call(code, rmode); 2576 call(code, rmode);
2602 call_wrapper.AfterCall(); 2577 call_wrapper.AfterCall();
2603 } else { 2578 } else {
2604 ASSERT(flag == JUMP_FUNCTION); 2579 ASSERT(flag == JUMP_FUNCTION);
2605 SetCallKind(ecx, call_kind);
2606 jmp(code, rmode); 2580 jmp(code, rmode);
2607 } 2581 }
2608 bind(&done); 2582 bind(&done);
2609 } 2583 }
2610 } 2584 }
2611 2585
2612 2586
2613 void MacroAssembler::InvokeFunction(Register fun, 2587 void MacroAssembler::InvokeFunction(Register fun,
2614 const ParameterCount& actual, 2588 const ParameterCount& actual,
2615 InvokeFlag flag, 2589 InvokeFlag flag,
2616 const CallWrapper& call_wrapper, 2590 const CallWrapper& call_wrapper) {
2617 CallKind call_kind) {
2618 // You can't call a function without a valid frame. 2591 // You can't call a function without a valid frame.
2619 ASSERT(flag == JUMP_FUNCTION || has_frame()); 2592 ASSERT(flag == JUMP_FUNCTION || has_frame());
2620 2593
2621 ASSERT(fun.is(edi)); 2594 ASSERT(fun.is(edi));
2622 mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); 2595 mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
2623 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); 2596 mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
2624 mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); 2597 mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset));
2625 SmiUntag(ebx); 2598 SmiUntag(ebx);
2626 2599
2627 ParameterCount expected(ebx); 2600 ParameterCount expected(ebx);
2628 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), 2601 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset),
2629 expected, actual, flag, call_wrapper, call_kind); 2602 expected, actual, flag, call_wrapper);
2630 } 2603 }
2631 2604
2632 2605
2633 void MacroAssembler::InvokeFunction(Register fun, 2606 void MacroAssembler::InvokeFunction(Register fun,
2634 const ParameterCount& expected, 2607 const ParameterCount& expected,
2635 const ParameterCount& actual, 2608 const ParameterCount& actual,
2636 InvokeFlag flag, 2609 InvokeFlag flag,
2637 const CallWrapper& call_wrapper, 2610 const CallWrapper& call_wrapper) {
2638 CallKind call_kind) {
2639 // You can't call a function without a valid frame. 2611 // You can't call a function without a valid frame.
2640 ASSERT(flag == JUMP_FUNCTION || has_frame()); 2612 ASSERT(flag == JUMP_FUNCTION || has_frame());
2641 2613
2642 ASSERT(fun.is(edi)); 2614 ASSERT(fun.is(edi));
2643 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); 2615 mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
2644 2616
2645 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), 2617 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset),
2646 expected, actual, flag, call_wrapper, call_kind); 2618 expected, actual, flag, call_wrapper);
2647 } 2619 }
2648 2620
2649 2621
2650 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, 2622 void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
2651 const ParameterCount& expected, 2623 const ParameterCount& expected,
2652 const ParameterCount& actual, 2624 const ParameterCount& actual,
2653 InvokeFlag flag, 2625 InvokeFlag flag,
2654 const CallWrapper& call_wrapper, 2626 const CallWrapper& call_wrapper) {
2655 CallKind call_kind) {
2656 LoadHeapObject(edi, function); 2627 LoadHeapObject(edi, function);
2657 InvokeFunction(edi, expected, actual, flag, call_wrapper, call_kind); 2628 InvokeFunction(edi, expected, actual, flag, call_wrapper);
2658 } 2629 }
2659 2630
2660 2631
2661 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, 2632 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id,
2662 InvokeFlag flag, 2633 InvokeFlag flag,
2663 const CallWrapper& call_wrapper) { 2634 const CallWrapper& call_wrapper) {
2664 // You can't call a builtin without a valid frame. 2635 // You can't call a builtin without a valid frame.
2665 ASSERT(flag == JUMP_FUNCTION || has_frame()); 2636 ASSERT(flag == JUMP_FUNCTION || has_frame());
2666 2637
2667 // Rely on the assertion to check that the number of provided 2638 // Rely on the assertion to check that the number of provided
2668 // arguments match the expected number of arguments. Fake a 2639 // arguments match the expected number of arguments. Fake a
2669 // parameter count to avoid emitting code to do the check. 2640 // parameter count to avoid emitting code to do the check.
2670 ParameterCount expected(0); 2641 ParameterCount expected(0);
2671 GetBuiltinFunction(edi, id); 2642 GetBuiltinFunction(edi, id);
2672 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), 2643 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset),
2673 expected, expected, flag, call_wrapper, CALL_AS_METHOD); 2644 expected, expected, flag, call_wrapper);
2674 } 2645 }
2675 2646
2676 2647
2677 void MacroAssembler::GetBuiltinFunction(Register target, 2648 void MacroAssembler::GetBuiltinFunction(Register target,
2678 Builtins::JavaScript id) { 2649 Builtins::JavaScript id) {
2679 // Load the JavaScript builtin function from the builtins object. 2650 // Load the JavaScript builtin function from the builtins object.
2680 mov(target, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); 2651 mov(target, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
2681 mov(target, FieldOperand(target, GlobalObject::kBuiltinsOffset)); 2652 mov(target, FieldOperand(target, GlobalObject::kBuiltinsOffset));
2682 mov(target, FieldOperand(target, 2653 mov(target, FieldOperand(target,
2683 JSBuiltinsObject::OffsetOfFunctionWithId(id))); 2654 JSBuiltinsObject::OffsetOfFunctionWithId(id)));
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
3694 cmp(scratch1, Immediate(DICTIONARY_ELEMENTS)); 3665 cmp(scratch1, Immediate(DICTIONARY_ELEMENTS));
3695 j(equal, found); 3666 j(equal, found);
3696 mov(current, FieldOperand(current, Map::kPrototypeOffset)); 3667 mov(current, FieldOperand(current, Map::kPrototypeOffset));
3697 cmp(current, Immediate(factory->null_value())); 3668 cmp(current, Immediate(factory->null_value()));
3698 j(not_equal, &loop_again); 3669 j(not_equal, &loop_again);
3699 } 3670 }
3700 3671
3701 } } // namespace v8::internal 3672 } } // namespace v8::internal
3702 3673
3703 #endif // V8_TARGET_ARCH_IA32 3674 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/ia32/stub-cache-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698