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

Side by Side Diff: src/ia32/lithium-codegen-ia32.cc

Issue 9178017: Allow call-known-global to be used for call-sites with mismatched number of arguments. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Relax call-constant-function restrictions as well Created 8 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/ast.cc ('k') | src/ia32/macro-assembler-ia32.h » ('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 2683 matching lines...) Expand 10 before | Expand all | Expand 10 after
2694 Register global = ToRegister(instr->global()); 2694 Register global = ToRegister(instr->global());
2695 Register result = ToRegister(instr->result()); 2695 Register result = ToRegister(instr->result());
2696 __ mov(result, FieldOperand(global, GlobalObject::kGlobalReceiverOffset)); 2696 __ mov(result, FieldOperand(global, GlobalObject::kGlobalReceiverOffset));
2697 } 2697 }
2698 2698
2699 2699
2700 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, 2700 void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
2701 int arity, 2701 int arity,
2702 LInstruction* instr, 2702 LInstruction* instr,
2703 CallKind call_kind) { 2703 CallKind call_kind) {
2704 // Change context if needed. 2704 bool can_invoke_directly = !function->NeedsArgumentsAdaption() ||
2705 bool change_context = 2705 function->shared()->formal_parameter_count() == arity;
2706 (info()->closure()->context() != function->context()) ||
2707 scope()->contains_with() ||
2708 (scope()->num_heap_slots() > 0);
2709 if (change_context) {
2710 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
2711 } else {
2712 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
2713 }
2714
2715 // Set eax to arguments count if adaption is not needed. Assumes that eax
2716 // is available to write to at this point.
2717 if (!function->NeedsArgumentsAdaption()) {
2718 __ mov(eax, arity);
2719 }
2720 2706
2721 LPointerMap* pointers = instr->pointer_map(); 2707 LPointerMap* pointers = instr->pointer_map();
2722 RecordPosition(pointers->position()); 2708 RecordPosition(pointers->position());
2723 2709
2724 // Invoke function. 2710 if (can_invoke_directly) {
2725 __ SetCallKind(ecx, call_kind); 2711 __ LoadHeapObject(edi, function);
2726 if (*function == *info()->closure()) { 2712
2727 __ CallSelf(); 2713 // Change context if needed.
2714 bool change_context =
2715 (info()->closure()->context() != function->context()) ||
2716 scope()->contains_with() ||
2717 (scope()->num_heap_slots() > 0);
2718
2719 if (change_context) {
2720 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
2721 } else {
2722 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
2723 }
2724
2725 // Set eax to arguments count if adaption is not needed. Assumes that eax
2726 // is available to write to at this point.
2727 if (!function->NeedsArgumentsAdaption()) {
2728 __ mov(eax, arity);
2729 }
2730
2731 // Invoke function directly.
2732 __ SetCallKind(ecx, call_kind);
2733 if (*function == *info()->closure()) {
2734 __ CallSelf();
2735 } else {
2736 __ call(FieldOperand(edi, JSFunction::kCodeEntryOffset));
2737 }
2738 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT);
2728 } else { 2739 } else {
2729 __ call(FieldOperand(edi, JSFunction::kCodeEntryOffset)); 2740 // We need to adapt arguments.
2741 SafepointGenerator generator(
2742 this, pointers, Safepoint::kLazyDeopt);
2743 ParameterCount count(arity);
2744 __ InvokeFunction(function, count, CALL_FUNCTION, generator, call_kind);
2730 } 2745 }
2731
2732 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT);
2733 } 2746 }
2734 2747
2735 2748
2736 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { 2749 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) {
2737 ASSERT(ToRegister(instr->result()).is(eax)); 2750 ASSERT(ToRegister(instr->result()).is(eax));
2738 __ LoadHeapObject(edi, instr->function());
2739 CallKnownFunction(instr->function(), 2751 CallKnownFunction(instr->function(),
2740 instr->arity(), 2752 instr->arity(),
2741 instr, 2753 instr,
2742 CALL_AS_METHOD); 2754 CALL_AS_METHOD);
2743 } 2755 }
2744 2756
2745 2757
2746 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr) { 2758 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr) {
2747 Register input_reg = ToRegister(instr->value()); 2759 Register input_reg = ToRegister(instr->value());
2748 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), 2760 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset),
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
3183 RelocInfo::Mode mode = RelocInfo::CODE_TARGET_CONTEXT; 3195 RelocInfo::Mode mode = RelocInfo::CODE_TARGET_CONTEXT;
3184 Handle<Code> ic = 3196 Handle<Code> ic =
3185 isolate()->stub_cache()->ComputeCallInitialize(arity, mode); 3197 isolate()->stub_cache()->ComputeCallInitialize(arity, mode);
3186 __ mov(ecx, instr->name()); 3198 __ mov(ecx, instr->name());
3187 CallCode(ic, mode, instr); 3199 CallCode(ic, mode, instr);
3188 } 3200 }
3189 3201
3190 3202
3191 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) { 3203 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) {
3192 ASSERT(ToRegister(instr->result()).is(eax)); 3204 ASSERT(ToRegister(instr->result()).is(eax));
3193 __ LoadHeapObject(edi, instr->target());
3194 CallKnownFunction(instr->target(), instr->arity(), instr, CALL_AS_FUNCTION); 3205 CallKnownFunction(instr->target(), instr->arity(), instr, CALL_AS_FUNCTION);
3195 } 3206 }
3196 3207
3197 3208
3198 void LCodeGen::DoCallNew(LCallNew* instr) { 3209 void LCodeGen::DoCallNew(LCallNew* instr) {
3199 ASSERT(ToRegister(instr->context()).is(esi)); 3210 ASSERT(ToRegister(instr->context()).is(esi));
3200 ASSERT(ToRegister(instr->constructor()).is(edi)); 3211 ASSERT(ToRegister(instr->constructor()).is(edi));
3201 ASSERT(ToRegister(instr->result()).is(eax)); 3212 ASSERT(ToRegister(instr->result()).is(eax));
3202 3213
3203 Handle<Code> builtin = isolate()->builtins()->JSConstructCall(); 3214 Handle<Code> builtin = isolate()->builtins()->JSConstructCall();
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after
4662 this, pointers, Safepoint::kLazyDeopt); 4673 this, pointers, Safepoint::kLazyDeopt);
4663 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4674 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4664 } 4675 }
4665 4676
4666 4677
4667 #undef __ 4678 #undef __
4668 4679
4669 } } // namespace v8::internal 4680 } } // namespace v8::internal
4670 4681
4671 #endif // V8_TARGET_ARCH_IA32 4682 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698