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

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

Issue 716183004: MIPS: Leaving a generator via an exception causes it to close. (Closed) Base URL: https://v8.googlecode.com/svn/branches/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 | Annotate | Revision Log
« no previous file with comments | « src/mips/full-codegen-mips.cc ('k') | 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_MIPS64 7 #if V8_TARGET_ARCH_MIPS64
8 8
9 // Note on Mips implementation: 9 // Note on Mips implementation:
10 // 10 //
(...skipping 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 Expression *value, 2173 Expression *value,
2174 JSGeneratorObject::ResumeMode resume_mode) { 2174 JSGeneratorObject::ResumeMode resume_mode) {
2175 // The value stays in a0, and is ultimately read by the resumed generator, as 2175 // The value stays in a0, and is ultimately read by the resumed generator, as
2176 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it 2176 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it
2177 // is read to throw the value when the resumed generator is already closed. 2177 // is read to throw the value when the resumed generator is already closed.
2178 // a1 will hold the generator object until the activation has been resumed. 2178 // a1 will hold the generator object until the activation has been resumed.
2179 VisitForStackValue(generator); 2179 VisitForStackValue(generator);
2180 VisitForAccumulatorValue(value); 2180 VisitForAccumulatorValue(value);
2181 __ pop(a1); 2181 __ pop(a1);
2182 2182
2183 // Check generator state.
2184 Label wrong_state, closed_state, done;
2185 __ ld(a3, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset));
2186 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0);
2187 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0);
2188 __ Branch(&closed_state, eq, a3, Operand(zero_reg));
2189 __ Branch(&wrong_state, lt, a3, Operand(zero_reg));
2190
2191 // Load suspended function and context. 2183 // Load suspended function and context.
2192 __ ld(cp, FieldMemOperand(a1, JSGeneratorObject::kContextOffset)); 2184 __ ld(cp, FieldMemOperand(a1, JSGeneratorObject::kContextOffset));
2193 __ ld(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); 2185 __ ld(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset));
2194 2186
2195 // Load receiver and store as the first argument. 2187 // Load receiver and store as the first argument.
2196 __ ld(a2, FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset)); 2188 __ ld(a2, FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset));
2197 __ push(a2); 2189 __ push(a2);
2198 2190
2199 // Push holes for the rest of the arguments to the generator function. 2191 // Push holes for the rest of the arguments to the generator function.
2200 __ ld(a3, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); 2192 __ ld(a3, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset));
2201 // The argument count is stored as int32_t on 64-bit platforms. 2193 // The argument count is stored as int32_t on 64-bit platforms.
2202 // TODO(plind): Smi on 32-bit platforms. 2194 // TODO(plind): Smi on 32-bit platforms.
2203 __ lw(a3, 2195 __ lw(a3,
2204 FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset)); 2196 FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset));
2205 __ LoadRoot(a2, Heap::kTheHoleValueRootIndex); 2197 __ LoadRoot(a2, Heap::kTheHoleValueRootIndex);
2206 Label push_argument_holes, push_frame; 2198 Label push_argument_holes, push_frame;
2207 __ bind(&push_argument_holes); 2199 __ bind(&push_argument_holes);
2208 __ Dsubu(a3, a3, Operand(1)); 2200 __ Dsubu(a3, a3, Operand(1));
2209 __ Branch(&push_frame, lt, a3, Operand(zero_reg)); 2201 __ Branch(&push_frame, lt, a3, Operand(zero_reg));
2210 __ push(a2); 2202 __ push(a2);
2211 __ jmp(&push_argument_holes); 2203 __ jmp(&push_argument_holes);
2212 2204
2213 // Enter a new JavaScript frame, and initialize its slots as they were when 2205 // Enter a new JavaScript frame, and initialize its slots as they were when
2214 // the generator was suspended. 2206 // the generator was suspended.
2215 Label resume_frame; 2207 Label resume_frame, done;
2216 __ bind(&push_frame); 2208 __ bind(&push_frame);
2217 __ Call(&resume_frame); 2209 __ Call(&resume_frame);
2218 __ jmp(&done); 2210 __ jmp(&done);
2219 __ bind(&resume_frame); 2211 __ bind(&resume_frame);
2220 // ra = return address. 2212 // ra = return address.
2221 // fp = caller's frame pointer. 2213 // fp = caller's frame pointer.
2222 // cp = callee's context, 2214 // cp = callee's context,
2223 // a4 = callee's JS function. 2215 // a4 = callee's JS function.
2224 __ Push(ra, fp, cp, a4); 2216 __ Push(ra, fp, cp, a4);
2225 // Adjust FP to point to saved FP. 2217 // Adjust FP to point to saved FP.
(...skipping 28 matching lines...) Expand all
2254 __ push(a2); 2246 __ push(a2);
2255 __ Branch(&push_operand_holes); 2247 __ Branch(&push_operand_holes);
2256 __ bind(&call_resume); 2248 __ bind(&call_resume);
2257 DCHECK(!result_register().is(a1)); 2249 DCHECK(!result_register().is(a1));
2258 __ Push(a1, result_register()); 2250 __ Push(a1, result_register());
2259 __ Push(Smi::FromInt(resume_mode)); 2251 __ Push(Smi::FromInt(resume_mode));
2260 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3); 2252 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3);
2261 // Not reached: the runtime call returns elsewhere. 2253 // Not reached: the runtime call returns elsewhere.
2262 __ stop("not-reached"); 2254 __ stop("not-reached");
2263 2255
2264 // Reach here when generator is closed.
2265 __ bind(&closed_state);
2266 if (resume_mode == JSGeneratorObject::NEXT) {
2267 // Return completed iterator result when generator is closed.
2268 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
2269 __ push(a2);
2270 // Pop value from top-of-stack slot; box result into result register.
2271 EmitCreateIteratorResult(true);
2272 } else {
2273 // Throw the provided value.
2274 __ push(a0);
2275 __ CallRuntime(Runtime::kThrow, 1);
2276 }
2277 __ jmp(&done);
2278
2279 // Throw error if we attempt to operate on a running generator.
2280 __ bind(&wrong_state);
2281 __ push(a1);
2282 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1);
2283
2284 __ bind(&done); 2256 __ bind(&done);
2285 context()->Plug(result_register()); 2257 context()->Plug(result_register());
2286 } 2258 }
2287 2259
2288 2260
2289 void FullCodeGenerator::EmitCreateIteratorResult(bool done) { 2261 void FullCodeGenerator::EmitCreateIteratorResult(bool done) {
2290 Label gc_required; 2262 Label gc_required;
2291 Label allocated; 2263 Label allocated;
2292 2264
2293 const int instance_size = 5 * kPointerSize; 2265 const int instance_size = 5 * kPointerSize;
(...skipping 2975 matching lines...) Expand 10 before | Expand all | Expand 10 after
5269 Assembler::target_address_at(pc_immediate_load_address)) == 5241 Assembler::target_address_at(pc_immediate_load_address)) ==
5270 reinterpret_cast<uint64_t>( 5242 reinterpret_cast<uint64_t>(
5271 isolate->builtins()->OsrAfterStackCheck()->entry())); 5243 isolate->builtins()->OsrAfterStackCheck()->entry()));
5272 return OSR_AFTER_STACK_CHECK; 5244 return OSR_AFTER_STACK_CHECK;
5273 } 5245 }
5274 5246
5275 5247
5276 } } // namespace v8::internal 5248 } } // namespace v8::internal
5277 5249
5278 #endif // V8_TARGET_ARCH_MIPS64 5250 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips/full-codegen-mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698