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

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

Issue 132623005: A64: Synchronize with r18642. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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/code-stubs-ia32.cc ('k') | src/ia32/ic-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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 #endif 100 #endif
101 }; 101 };
102 102
103 103
104 // Generate code for a JS function. On entry to the function the receiver 104 // Generate code for a JS function. On entry to the function the receiver
105 // and arguments have been pushed on the stack left to right, with the 105 // and arguments have been pushed on the stack left to right, with the
106 // return address on top of them. The actual argument count matches the 106 // return address on top of them. The actual argument count matches the
107 // formal parameter count expected by the function. 107 // formal parameter count expected by the function.
108 // 108 //
109 // The live registers are: 109 // The live registers are:
110 // o ecx: CallKind
111 // o edi: the JS function object being called (i.e. ourselves) 110 // o edi: the JS function object being called (i.e. ourselves)
112 // o esi: our context 111 // o esi: our context
113 // o ebp: our caller's frame pointer 112 // o ebp: our caller's frame pointer
114 // o esp: stack pointer (pointing to return address) 113 // o esp: stack pointer (pointing to return address)
115 // 114 //
116 // The function builds a JS frame. Please see JavaScriptFrameConstants in 115 // The function builds a JS frame. Please see JavaScriptFrameConstants in
117 // frames-ia32.h for its layout. 116 // frames-ia32.h for its layout.
118 void FullCodeGenerator::Generate() { 117 void FullCodeGenerator::Generate() {
119 CompilationInfo* info = info_; 118 CompilationInfo* info = info_;
120 handler_table_ = 119 handler_table_ =
(...skipping 10 matching lines...) Expand all
131 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { 130 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) {
132 __ int3(); 131 __ int3();
133 } 132 }
134 #endif 133 #endif
135 134
136 // Classic mode functions and builtins need to replace the receiver with the 135 // Classic mode functions and builtins need to replace the receiver with the
137 // global proxy when called as functions (without an explicit receiver 136 // global proxy when called as functions (without an explicit receiver
138 // object). 137 // object).
139 if (info->is_classic_mode() && !info->is_native()) { 138 if (info->is_classic_mode() && !info->is_native()) {
140 Label ok; 139 Label ok;
141 __ test(ecx, ecx);
142 __ j(zero, &ok, Label::kNear);
143
144 // +1 for return address. 140 // +1 for return address.
145 int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize; 141 int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize;
146 __ mov(ecx, Operand(esp, receiver_offset)); 142 __ mov(ecx, Operand(esp, receiver_offset));
147 143
148 __ cmp(ecx, isolate()->factory()->undefined_value()); 144 __ cmp(ecx, isolate()->factory()->undefined_value());
149 __ j(not_equal, &ok, Label::kNear); 145 __ j(not_equal, &ok, Label::kNear);
150 146
151 __ mov(ecx, GlobalObjectOperand()); 147 __ mov(ecx, GlobalObjectOperand());
152 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset)); 148 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset));
153 149
(...skipping 1917 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 break; 2067 break;
2072 } 2068 }
2073 } 2069 }
2074 } 2070 }
2075 2071
2076 2072
2077 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, 2073 void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
2078 Expression *value, 2074 Expression *value,
2079 JSGeneratorObject::ResumeMode resume_mode) { 2075 JSGeneratorObject::ResumeMode resume_mode) {
2080 // The value stays in eax, and is ultimately read by the resumed generator, as 2076 // The value stays in eax, and is ultimately read by the resumed generator, as
2081 // if the CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. ebx 2077 // if the CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it
2082 // will hold the generator object until the activation has been resumed. 2078 // is read to throw the value when the resumed generator is already closed.
2079 // ebx will hold the generator object until the activation has been resumed.
2083 VisitForStackValue(generator); 2080 VisitForStackValue(generator);
2084 VisitForAccumulatorValue(value); 2081 VisitForAccumulatorValue(value);
2085 __ pop(ebx); 2082 __ pop(ebx);
2086 2083
2087 // Check generator state. 2084 // Check generator state.
2088 Label wrong_state, done; 2085 Label wrong_state, closed_state, done;
2089 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting <= 0); 2086 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0);
2090 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed <= 0); 2087 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0);
2091 __ cmp(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset), 2088 __ cmp(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset),
2092 Immediate(Smi::FromInt(0))); 2089 Immediate(Smi::FromInt(0)));
2093 __ j(less_equal, &wrong_state); 2090 __ j(equal, &closed_state);
2091 __ j(less, &wrong_state);
2094 2092
2095 // Load suspended function and context. 2093 // Load suspended function and context.
2096 __ mov(esi, FieldOperand(ebx, JSGeneratorObject::kContextOffset)); 2094 __ mov(esi, FieldOperand(ebx, JSGeneratorObject::kContextOffset));
2097 __ mov(edi, FieldOperand(ebx, JSGeneratorObject::kFunctionOffset)); 2095 __ mov(edi, FieldOperand(ebx, JSGeneratorObject::kFunctionOffset));
2098 2096
2099 // Push receiver. 2097 // Push receiver.
2100 __ push(FieldOperand(ebx, JSGeneratorObject::kReceiverOffset)); 2098 __ push(FieldOperand(ebx, JSGeneratorObject::kReceiverOffset));
2101 2099
2102 // Push holes for arguments to generator function. 2100 // Push holes for arguments to generator function.
2103 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); 2101 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2153 __ push(ecx); 2151 __ push(ecx);
2154 __ jmp(&push_operand_holes); 2152 __ jmp(&push_operand_holes);
2155 __ bind(&call_resume); 2153 __ bind(&call_resume);
2156 __ push(ebx); 2154 __ push(ebx);
2157 __ push(result_register()); 2155 __ push(result_register());
2158 __ Push(Smi::FromInt(resume_mode)); 2156 __ Push(Smi::FromInt(resume_mode));
2159 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3); 2157 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3);
2160 // Not reached: the runtime call returns elsewhere. 2158 // Not reached: the runtime call returns elsewhere.
2161 __ Abort(kGeneratorFailedToResume); 2159 __ Abort(kGeneratorFailedToResume);
2162 2160
2161 // Reach here when generator is closed.
2162 __ bind(&closed_state);
2163 if (resume_mode == JSGeneratorObject::NEXT) {
2164 // Return completed iterator result when generator is closed.
2165 __ push(Immediate(isolate()->factory()->undefined_value()));
2166 // Pop value from top-of-stack slot; box result into result register.
2167 EmitCreateIteratorResult(true);
2168 } else {
2169 // Throw the provided value.
2170 __ push(eax);
2171 __ CallRuntime(Runtime::kThrow, 1);
2172 }
2173 __ jmp(&done);
2174
2163 // Throw error if we attempt to operate on a running generator. 2175 // Throw error if we attempt to operate on a running generator.
2164 __ bind(&wrong_state); 2176 __ bind(&wrong_state);
2165 __ push(ebx); 2177 __ push(ebx);
2166 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1); 2178 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1);
2167 2179
2168 __ bind(&done); 2180 __ bind(&done);
2169 context()->Plug(result_register()); 2181 context()->Plug(result_register());
2170 } 2182 }
2171 2183
2172 2184
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
2550 int arg_count = args->length(); 2562 int arg_count = args->length();
2551 { PreservePositionScope scope(masm()->positions_recorder()); 2563 { PreservePositionScope scope(masm()->positions_recorder());
2552 for (int i = 0; i < arg_count; i++) { 2564 for (int i = 0; i < arg_count; i++) {
2553 VisitForStackValue(args->at(i)); 2565 VisitForStackValue(args->at(i));
2554 } 2566 }
2555 __ Set(ecx, Immediate(name)); 2567 __ Set(ecx, Immediate(name));
2556 } 2568 }
2557 // Record source position of the IC call. 2569 // Record source position of the IC call.
2558 SetSourcePosition(expr->position()); 2570 SetSourcePosition(expr->position());
2559 Handle<Code> ic = 2571 Handle<Code> ic =
2560 isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode); 2572 isolate()->stub_cache()->ComputeCallInitialize(arg_count);
2561 TypeFeedbackId ast_id = mode == CONTEXTUAL 2573 TypeFeedbackId ast_id = mode == CONTEXTUAL
2562 ? TypeFeedbackId::None() 2574 ? TypeFeedbackId::None()
2563 : expr->CallFeedbackId(); 2575 : expr->CallFeedbackId();
2564 CallIC(ic, mode, ast_id); 2576 CallIC(ic, mode, ast_id);
2565 RecordJSReturnSite(expr); 2577 RecordJSReturnSite(expr);
2566 // Restore context register. 2578 // Restore context register.
2567 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 2579 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
2568 context()->Plug(eax); 2580 context()->Plug(eax);
2569 } 2581 }
2570 2582
(...skipping 23 matching lines...) Expand all
2594 isolate()->stub_cache()->ComputeKeyedCallInitialize(arg_count); 2606 isolate()->stub_cache()->ComputeKeyedCallInitialize(arg_count);
2595 __ mov(ecx, Operand(esp, (arg_count + 1) * kPointerSize)); // Key. 2607 __ mov(ecx, Operand(esp, (arg_count + 1) * kPointerSize)); // Key.
2596 CallIC(ic, NOT_CONTEXTUAL, expr->CallFeedbackId()); 2608 CallIC(ic, NOT_CONTEXTUAL, expr->CallFeedbackId());
2597 RecordJSReturnSite(expr); 2609 RecordJSReturnSite(expr);
2598 // Restore context register. 2610 // Restore context register.
2599 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 2611 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
2600 context()->DropAndPlug(1, eax); // Drop the key still on the stack. 2612 context()->DropAndPlug(1, eax); // Drop the key still on the stack.
2601 } 2613 }
2602 2614
2603 2615
2604 void FullCodeGenerator::EmitCallWithStub(Call* expr, CallFunctionFlags flags) { 2616 void FullCodeGenerator::EmitCallWithStub(Call* expr) {
2605 // Code common for calls using the call stub. 2617 // Code common for calls using the call stub.
2606 ZoneList<Expression*>* args = expr->arguments(); 2618 ZoneList<Expression*>* args = expr->arguments();
2607 int arg_count = args->length(); 2619 int arg_count = args->length();
2608 { PreservePositionScope scope(masm()->positions_recorder()); 2620 { PreservePositionScope scope(masm()->positions_recorder());
2609 for (int i = 0; i < arg_count; i++) { 2621 for (int i = 0; i < arg_count; i++) {
2610 VisitForStackValue(args->at(i)); 2622 VisitForStackValue(args->at(i));
2611 } 2623 }
2612 } 2624 }
2613 // Record source position for debugger. 2625 // Record source position for debugger.
2614 SetSourcePosition(expr->position()); 2626 SetSourcePosition(expr->position());
2615 2627
2616 // Record call targets in unoptimized code.
2617 flags = static_cast<CallFunctionFlags>(flags | RECORD_CALL_TARGET);
2618 Handle<Object> uninitialized = 2628 Handle<Object> uninitialized =
2619 TypeFeedbackCells::UninitializedSentinel(isolate()); 2629 TypeFeedbackCells::UninitializedSentinel(isolate());
2620 Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized); 2630 Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized);
2621 RecordTypeFeedbackCell(expr->CallFeedbackId(), cell); 2631 RecordTypeFeedbackCell(expr->CallFeedbackId(), cell);
2622 __ mov(ebx, cell); 2632 __ mov(ebx, cell);
2623 2633
2624 CallFunctionStub stub(arg_count, flags); 2634 // Record call targets in unoptimized code.
2635 CallFunctionStub stub(arg_count, RECORD_CALL_TARGET);
2625 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); 2636 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize));
2626 __ CallStub(&stub, expr->CallFeedbackId()); 2637 __ CallStub(&stub, expr->CallFeedbackId());
2627 2638
2628 RecordJSReturnSite(expr); 2639 RecordJSReturnSite(expr);
2629 // Restore context register. 2640 // Restore context register.
2630 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 2641 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
2631 context()->DropAndPlug(1, eax); 2642 context()->DropAndPlug(1, eax);
2632 } 2643 }
2633 2644
2634 2645
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2730 // Push function. 2741 // Push function.
2731 __ push(eax); 2742 __ push(eax);
2732 // The receiver is implicitly the global receiver. Indicate this by 2743 // The receiver is implicitly the global receiver. Indicate this by
2733 // passing the hole to the call function stub. 2744 // passing the hole to the call function stub.
2734 __ push(Immediate(isolate()->factory()->undefined_value())); 2745 __ push(Immediate(isolate()->factory()->undefined_value()));
2735 __ bind(&call); 2746 __ bind(&call);
2736 } 2747 }
2737 2748
2738 // The receiver is either the global receiver or an object found by 2749 // The receiver is either the global receiver or an object found by
2739 // LoadContextSlot. 2750 // LoadContextSlot.
2740 EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS); 2751 EmitCallWithStub(expr);
2741 2752
2742 } else if (property != NULL) { 2753 } else if (property != NULL) {
2743 { PreservePositionScope scope(masm()->positions_recorder()); 2754 { PreservePositionScope scope(masm()->positions_recorder());
2744 VisitForStackValue(property->obj()); 2755 VisitForStackValue(property->obj());
2745 } 2756 }
2746 if (property->key()->IsPropertyName()) { 2757 if (property->key()->IsPropertyName()) {
2747 EmitCallWithIC(expr, 2758 EmitCallWithIC(expr,
2748 property->key()->AsLiteral()->value(), 2759 property->key()->AsLiteral()->value(),
2749 NOT_CONTEXTUAL); 2760 NOT_CONTEXTUAL);
2750 } else { 2761 } else {
2751 EmitKeyedCallWithIC(expr, property->key()); 2762 EmitKeyedCallWithIC(expr, property->key());
2752 } 2763 }
2753 2764
2754 } else { 2765 } else {
2755 // Call to an arbitrary expression not handled specially above. 2766 // Call to an arbitrary expression not handled specially above.
2756 { PreservePositionScope scope(masm()->positions_recorder()); 2767 { PreservePositionScope scope(masm()->positions_recorder());
2757 VisitForStackValue(callee); 2768 VisitForStackValue(callee);
2758 } 2769 }
2759 __ push(Immediate(isolate()->factory()->undefined_value())); 2770 __ push(Immediate(isolate()->factory()->undefined_value()));
2760 // Emit function call. 2771 // Emit function call.
2761 EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS); 2772 EmitCallWithStub(expr);
2762 } 2773 }
2763 2774
2764 #ifdef DEBUG 2775 #ifdef DEBUG
2765 // RecordJSReturnSite should have been called. 2776 // RecordJSReturnSite should have been called.
2766 ASSERT(expr->return_is_recorded_); 2777 ASSERT(expr->return_is_recorded_);
2767 #endif 2778 #endif
2768 } 2779 }
2769 2780
2770 2781
2771 void FullCodeGenerator::VisitCallNew(CallNew* expr) { 2782 void FullCodeGenerator::VisitCallNew(CallNew* expr) {
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
3686 3697
3687 Label runtime, done; 3698 Label runtime, done;
3688 // Check for non-function argument (including proxy). 3699 // Check for non-function argument (including proxy).
3689 __ JumpIfSmi(eax, &runtime); 3700 __ JumpIfSmi(eax, &runtime);
3690 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); 3701 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx);
3691 __ j(not_equal, &runtime); 3702 __ j(not_equal, &runtime);
3692 3703
3693 // InvokeFunction requires the function in edi. Move it in there. 3704 // InvokeFunction requires the function in edi. Move it in there.
3694 __ mov(edi, result_register()); 3705 __ mov(edi, result_register());
3695 ParameterCount count(arg_count); 3706 ParameterCount count(arg_count);
3696 __ InvokeFunction(edi, count, CALL_FUNCTION, 3707 __ InvokeFunction(edi, count, CALL_FUNCTION, NullCallWrapper());
3697 NullCallWrapper(), CALL_AS_FUNCTION);
3698 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 3708 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
3699 __ jmp(&done); 3709 __ jmp(&done);
3700 3710
3701 __ bind(&runtime); 3711 __ bind(&runtime);
3702 __ push(eax); 3712 __ push(eax);
3703 __ CallRuntime(Runtime::kCall, args->length()); 3713 __ CallRuntime(Runtime::kCall, args->length());
3704 __ bind(&done); 3714 __ bind(&done);
3705 3715
3706 context()->Plug(eax); 3716 context()->Plug(eax);
3707 } 3717 }
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
4128 4138
4129 // Push the arguments ("left-to-right"). 4139 // Push the arguments ("left-to-right").
4130 int arg_count = args->length(); 4140 int arg_count = args->length();
4131 for (int i = 0; i < arg_count; i++) { 4141 for (int i = 0; i < arg_count; i++) {
4132 VisitForStackValue(args->at(i)); 4142 VisitForStackValue(args->at(i));
4133 } 4143 }
4134 4144
4135 if (expr->is_jsruntime()) { 4145 if (expr->is_jsruntime()) {
4136 // Call the JS runtime function via a call IC. 4146 // Call the JS runtime function via a call IC.
4137 __ Set(ecx, Immediate(expr->name())); 4147 __ Set(ecx, Immediate(expr->name()));
4138 ContextualMode mode = NOT_CONTEXTUAL; 4148 Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arg_count);
4139 Handle<Code> ic = 4149 CallIC(ic, NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId());
4140 isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
4141 CallIC(ic, mode, expr->CallRuntimeFeedbackId());
4142 // Restore context register. 4150 // Restore context register.
4143 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 4151 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
4144 } else { 4152 } else {
4145 // Call the C runtime function. 4153 // Call the C runtime function.
4146 __ CallRuntime(expr->function(), arg_count); 4154 __ CallRuntime(expr->function(), arg_count);
4147 } 4155 }
4148 context()->Plug(eax); 4156 context()->Plug(eax);
4149 } 4157 }
4150 4158
4151 4159
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
4890 4898
4891 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4899 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4892 Assembler::target_address_at(call_target_address)); 4900 Assembler::target_address_at(call_target_address));
4893 return OSR_AFTER_STACK_CHECK; 4901 return OSR_AFTER_STACK_CHECK;
4894 } 4902 }
4895 4903
4896 4904
4897 } } // namespace v8::internal 4905 } } // namespace v8::internal
4898 4906
4899 #endif // V8_TARGET_ARCH_IA32 4907 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/ia32/ic-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698