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

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

Issue 724643002: X87: Leaving a generator via an exception causes it to close (Closed) Base URL: https://chromium.googlesource.com/external/v8.git@bleeding_edge
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X87 7 #if V8_TARGET_ARCH_X87
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 2094 matching lines...) Expand 10 before | Expand all | Expand 10 after
2105 Expression *value, 2105 Expression *value,
2106 JSGeneratorObject::ResumeMode resume_mode) { 2106 JSGeneratorObject::ResumeMode resume_mode) {
2107 // The value stays in eax, and is ultimately read by the resumed generator, as 2107 // The value stays in eax, and is ultimately read by the resumed generator, as
2108 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it 2108 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it
2109 // is read to throw the value when the resumed generator is already closed. 2109 // is read to throw the value when the resumed generator is already closed.
2110 // ebx will hold the generator object until the activation has been resumed. 2110 // ebx will hold the generator object until the activation has been resumed.
2111 VisitForStackValue(generator); 2111 VisitForStackValue(generator);
2112 VisitForAccumulatorValue(value); 2112 VisitForAccumulatorValue(value);
2113 __ pop(ebx); 2113 __ pop(ebx);
2114 2114
2115 // Check generator state.
2116 Label wrong_state, closed_state, done;
2117 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0);
2118 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0);
2119 __ cmp(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset),
2120 Immediate(Smi::FromInt(0)));
2121 __ j(equal, &closed_state);
2122 __ j(less, &wrong_state);
2123
2124 // Load suspended function and context. 2115 // Load suspended function and context.
2125 __ mov(esi, FieldOperand(ebx, JSGeneratorObject::kContextOffset)); 2116 __ mov(esi, FieldOperand(ebx, JSGeneratorObject::kContextOffset));
2126 __ mov(edi, FieldOperand(ebx, JSGeneratorObject::kFunctionOffset)); 2117 __ mov(edi, FieldOperand(ebx, JSGeneratorObject::kFunctionOffset));
2127 2118
2128 // Push receiver. 2119 // Push receiver.
2129 __ push(FieldOperand(ebx, JSGeneratorObject::kReceiverOffset)); 2120 __ push(FieldOperand(ebx, JSGeneratorObject::kReceiverOffset));
2130 2121
2131 // Push holes for arguments to generator function. 2122 // Push holes for arguments to generator function.
2132 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); 2123 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
2133 __ mov(edx, 2124 __ mov(edx,
2134 FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); 2125 FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset));
2135 __ mov(ecx, isolate()->factory()->the_hole_value()); 2126 __ mov(ecx, isolate()->factory()->the_hole_value());
2136 Label push_argument_holes, push_frame; 2127 Label push_argument_holes, push_frame;
2137 __ bind(&push_argument_holes); 2128 __ bind(&push_argument_holes);
2138 __ sub(edx, Immediate(Smi::FromInt(1))); 2129 __ sub(edx, Immediate(Smi::FromInt(1)));
2139 __ j(carry, &push_frame); 2130 __ j(carry, &push_frame);
2140 __ push(ecx); 2131 __ push(ecx);
2141 __ jmp(&push_argument_holes); 2132 __ jmp(&push_argument_holes);
2142 2133
2143 // Enter a new JavaScript frame, and initialize its slots as they were when 2134 // Enter a new JavaScript frame, and initialize its slots as they were when
2144 // the generator was suspended. 2135 // the generator was suspended.
2145 Label resume_frame; 2136 Label resume_frame, done;
2146 __ bind(&push_frame); 2137 __ bind(&push_frame);
2147 __ call(&resume_frame); 2138 __ call(&resume_frame);
2148 __ jmp(&done); 2139 __ jmp(&done);
2149 __ bind(&resume_frame); 2140 __ bind(&resume_frame);
2150 __ push(ebp); // Caller's frame pointer. 2141 __ push(ebp); // Caller's frame pointer.
2151 __ mov(ebp, esp); 2142 __ mov(ebp, esp);
2152 __ push(esi); // Callee's context. 2143 __ push(esi); // Callee's context.
2153 __ push(edi); // Callee's JS Function. 2144 __ push(edi); // Callee's JS Function.
2154 2145
2155 // Load the operand stack size. 2146 // Load the operand stack size.
(...skipping 26 matching lines...) Expand all
2182 __ push(ecx); 2173 __ push(ecx);
2183 __ jmp(&push_operand_holes); 2174 __ jmp(&push_operand_holes);
2184 __ bind(&call_resume); 2175 __ bind(&call_resume);
2185 __ push(ebx); 2176 __ push(ebx);
2186 __ push(result_register()); 2177 __ push(result_register());
2187 __ Push(Smi::FromInt(resume_mode)); 2178 __ Push(Smi::FromInt(resume_mode));
2188 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3); 2179 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3);
2189 // Not reached: the runtime call returns elsewhere. 2180 // Not reached: the runtime call returns elsewhere.
2190 __ Abort(kGeneratorFailedToResume); 2181 __ Abort(kGeneratorFailedToResume);
2191 2182
2192 // Reach here when generator is closed.
2193 __ bind(&closed_state);
2194 if (resume_mode == JSGeneratorObject::NEXT) {
2195 // Return completed iterator result when generator is closed.
2196 __ push(Immediate(isolate()->factory()->undefined_value()));
2197 // Pop value from top-of-stack slot; box result into result register.
2198 EmitCreateIteratorResult(true);
2199 } else {
2200 // Throw the provided value.
2201 __ push(eax);
2202 __ CallRuntime(Runtime::kThrow, 1);
2203 }
2204 __ jmp(&done);
2205
2206 // Throw error if we attempt to operate on a running generator.
2207 __ bind(&wrong_state);
2208 __ push(ebx);
2209 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1);
2210
2211 __ bind(&done); 2183 __ bind(&done);
2212 context()->Plug(result_register()); 2184 context()->Plug(result_register());
2213 } 2185 }
2214 2186
2215 2187
2216 void FullCodeGenerator::EmitCreateIteratorResult(bool done) { 2188 void FullCodeGenerator::EmitCreateIteratorResult(bool done) {
2217 Label gc_required; 2189 Label gc_required;
2218 Label allocated; 2190 Label allocated;
2219 2191
2220 const int instance_size = 5 * kPointerSize; 2192 const int instance_size = 5 * kPointerSize;
(...skipping 2969 matching lines...) Expand 10 before | Expand all | Expand 10 after
5190 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5162 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5191 Assembler::target_address_at(call_target_address, 5163 Assembler::target_address_at(call_target_address,
5192 unoptimized_code)); 5164 unoptimized_code));
5193 return OSR_AFTER_STACK_CHECK; 5165 return OSR_AFTER_STACK_CHECK;
5194 } 5166 }
5195 5167
5196 5168
5197 } } // namespace v8::internal 5169 } } // namespace v8::internal
5198 5170
5199 #endif // V8_TARGET_ARCH_X87 5171 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698