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

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

Issue 16820004: MIPS: Allocate generator result objects before unwinding try handlers (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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 | « 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 // 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 1980 matching lines...) Expand 10 before | Expand all | Expand 10 after
1991 } 1991 }
1992 1992
1993 1993
1994 void FullCodeGenerator::VisitYield(Yield* expr) { 1994 void FullCodeGenerator::VisitYield(Yield* expr) {
1995 Comment cmnt(masm_, "[ Yield"); 1995 Comment cmnt(masm_, "[ Yield");
1996 // Evaluate yielded value first; the initial iterator definition depends on 1996 // Evaluate yielded value first; the initial iterator definition depends on
1997 // this. It stays on the stack while we update the iterator. 1997 // this. It stays on the stack while we update the iterator.
1998 VisitForStackValue(expr->expression()); 1998 VisitForStackValue(expr->expression());
1999 1999
2000 switch (expr->yield_kind()) { 2000 switch (expr->yield_kind()) {
2001 case Yield::INITIAL: 2001 case Yield::SUSPEND:
2002 case Yield::SUSPEND: { 2002 // Pop value from top-of-stack slot; box result into result register.
2003 EmitCreateIteratorResult(false);
2004 __ push(result_register());
2005 // Fall through.
2006 case Yield::INITIAL: {
2003 VisitForStackValue(expr->generator_object()); 2007 VisitForStackValue(expr->generator_object());
2004 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); 2008 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
2005 __ lw(context_register(), 2009 __ lw(context_register(),
2006 MemOperand(fp, StandardFrameConstants::kContextOffset)); 2010 MemOperand(fp, StandardFrameConstants::kContextOffset));
2007 2011
2008 Label resume; 2012 Label resume;
2009 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); 2013 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
2010 __ Branch(&resume, ne, result_register(), Operand(at)); 2014 __ Branch(&resume, ne, result_register(), Operand(at));
2011 if (expr->yield_kind() == Yield::SUSPEND) { 2015 __ pop(result_register());
2012 EmitReturnIteratorResult(false); 2016 EmitReturnSequence();
2013 } else {
2014 __ pop(result_register());
2015 EmitReturnSequence();
2016 }
2017 2017
2018 __ bind(&resume); 2018 __ bind(&resume);
2019 context()->Plug(result_register()); 2019 context()->Plug(result_register());
2020 break; 2020 break;
2021 } 2021 }
2022 2022
2023 case Yield::FINAL: { 2023 case Yield::FINAL: {
2024 VisitForAccumulatorValue(expr->generator_object()); 2024 VisitForAccumulatorValue(expr->generator_object());
2025 __ li(a1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); 2025 __ li(a1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed)));
2026 __ sw(a1, FieldMemOperand(result_register(), 2026 __ sw(a1, FieldMemOperand(result_register(),
2027 JSGeneratorObject::kContinuationOffset)); 2027 JSGeneratorObject::kContinuationOffset));
2028 EmitReturnIteratorResult(true); 2028 // Pop value from top-of-stack slot, box result into result register.
2029 EmitCreateIteratorResult(true);
2030 EmitUnwindBeforeReturn();
2031 EmitReturnSequence();
2029 break; 2032 break;
2030 } 2033 }
2031 2034
2032 case Yield::DELEGATING: { 2035 case Yield::DELEGATING: {
2033 VisitForStackValue(expr->generator_object()); 2036 VisitForStackValue(expr->generator_object());
2034 2037
2035 // Initial stack layout is as follows: 2038 // Initial stack layout is as follows:
2036 // [sp + 1 * kPointerSize] iter 2039 // [sp + 1 * kPointerSize] iter
2037 // [sp + 0 * kPointerSize] g 2040 // [sp + 0 * kPointerSize] g
2038 2041
(...skipping 11 matching lines...) Expand all
2050 __ push(a0); // exception 2053 __ push(a0); // exception
2051 __ mov(a0, a3); // iter 2054 __ mov(a0, a3); // iter
2052 __ LoadRoot(a2, Heap::kthrow_stringRootIndex); // "throw" 2055 __ LoadRoot(a2, Heap::kthrow_stringRootIndex); // "throw"
2053 Handle<Code> throw_ic = isolate()->builtins()->LoadIC_Initialize(); 2056 Handle<Code> throw_ic = isolate()->builtins()->LoadIC_Initialize();
2054 CallIC(throw_ic); // iter.throw in a0 2057 CallIC(throw_ic); // iter.throw in a0
2055 __ mov(a0, v0); 2058 __ mov(a0, v0);
2056 __ jmp(&l_call); 2059 __ jmp(&l_call);
2057 2060
2058 // try { received = yield result.value } 2061 // try { received = yield result.value }
2059 __ bind(&l_try); 2062 __ bind(&l_try);
2060 __ pop(a0); // result.value 2063 EmitCreateIteratorResult(false); // pop and box to v0
2061 __ PushTryHandler(StackHandler::CATCH, expr->index()); 2064 __ PushTryHandler(StackHandler::CATCH, expr->index());
2062 const int handler_size = StackHandlerConstants::kSize; 2065 const int handler_size = StackHandlerConstants::kSize;
2063 __ push(a0); // result.value 2066 __ push(a0); // result
2064 __ lw(a3, MemOperand(sp, (0 + 1) * kPointerSize + handler_size)); // g 2067 __ lw(a3, MemOperand(sp, (0 + 1) * kPointerSize + handler_size)); // g
2065 __ push(a3); // g 2068 __ push(a3); // g
2066 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); 2069 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
2067 __ mov(a0, v0); 2070 __ mov(a0, v0);
2068 __ lw(context_register(), 2071 __ lw(context_register(),
2069 MemOperand(fp, StandardFrameConstants::kContextOffset)); 2072 MemOperand(fp, StandardFrameConstants::kContextOffset));
2070 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); 2073 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
2071 __ Branch(&l_resume, ne, a0, Operand(at)); 2074 __ Branch(&l_resume, ne, a0, Operand(at));
2072 EmitReturnIteratorResult(false); 2075 __ pop(v0); // result
2076 EmitReturnSequence();
2073 __ mov(a0, v0); 2077 __ mov(a0, v0);
2074 __ bind(&l_resume); // received in a0 2078 __ bind(&l_resume); // received in a0
2075 __ PopTryHandler(); 2079 __ PopTryHandler();
2076 2080
2077 // receiver = iter; f = iter.next; arg = received; 2081 // receiver = iter; f = iter.next; arg = received;
2078 __ bind(&l_next); 2082 __ bind(&l_next);
2079 __ lw(a3, MemOperand(sp, 1 * kPointerSize)); // iter 2083 __ lw(a3, MemOperand(sp, 1 * kPointerSize)); // iter
2080 __ push(a3); // iter 2084 __ push(a3); // iter
2081 __ push(a0); // received 2085 __ push(a0); // received
2082 __ mov(a0, a3); // iter 2086 __ mov(a0, a3); // iter
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2219 // Throw error if we attempt to operate on a running generator. 2223 // Throw error if we attempt to operate on a running generator.
2220 __ bind(&wrong_state); 2224 __ bind(&wrong_state);
2221 __ push(a1); 2225 __ push(a1);
2222 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1); 2226 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1);
2223 2227
2224 __ bind(&done); 2228 __ bind(&done);
2225 context()->Plug(result_register()); 2229 context()->Plug(result_register());
2226 } 2230 }
2227 2231
2228 2232
2229 void FullCodeGenerator::EmitReturnIteratorResult(bool done) { 2233 void FullCodeGenerator::EmitCreateIteratorResult(bool done) {
2230 Label gc_required; 2234 Label gc_required;
2231 Label allocated; 2235 Label allocated;
2232 2236
2233 Handle<Map> map(isolate()->native_context()->generator_result_map()); 2237 Handle<Map> map(isolate()->native_context()->generator_result_map());
2234 2238
2235 __ Allocate(map->instance_size(), a0, a2, a3, &gc_required, TAG_OBJECT); 2239 __ Allocate(map->instance_size(), a0, a2, a3, &gc_required, TAG_OBJECT);
2240 __ jmp(&allocated);
2241
2242 __ bind(&gc_required);
2243 __ Push(Smi::FromInt(map->instance_size()));
2244 __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
2245 __ lw(context_register(),
2246 MemOperand(fp, StandardFrameConstants::kContextOffset));
2236 2247
2237 __ bind(&allocated); 2248 __ bind(&allocated);
2238 __ li(a1, Operand(map)); 2249 __ li(a1, Operand(map));
2239 __ pop(a2); 2250 __ pop(a2);
2240 __ li(a3, Operand(isolate()->factory()->ToBoolean(done))); 2251 __ li(a3, Operand(isolate()->factory()->ToBoolean(done)));
2241 __ li(t0, Operand(isolate()->factory()->empty_fixed_array())); 2252 __ li(t0, Operand(isolate()->factory()->empty_fixed_array()));
2242 ASSERT_EQ(map->instance_size(), 5 * kPointerSize); 2253 ASSERT_EQ(map->instance_size(), 5 * kPointerSize);
2243 __ sw(a1, FieldMemOperand(a0, HeapObject::kMapOffset)); 2254 __ sw(a1, FieldMemOperand(a0, HeapObject::kMapOffset));
2244 __ sw(t0, FieldMemOperand(a0, JSObject::kPropertiesOffset)); 2255 __ sw(t0, FieldMemOperand(a0, JSObject::kPropertiesOffset));
2245 __ sw(t0, FieldMemOperand(a0, JSObject::kElementsOffset)); 2256 __ sw(t0, FieldMemOperand(a0, JSObject::kElementsOffset));
2246 __ sw(a2, 2257 __ sw(a2,
2247 FieldMemOperand(a0, JSGeneratorObject::kResultValuePropertyOffset)); 2258 FieldMemOperand(a0, JSGeneratorObject::kResultValuePropertyOffset));
2248 __ sw(a3, 2259 __ sw(a3,
2249 FieldMemOperand(a0, JSGeneratorObject::kResultDonePropertyOffset)); 2260 FieldMemOperand(a0, JSGeneratorObject::kResultDonePropertyOffset));
2250 2261
2251 // Only the value field needs a write barrier, as the other values are in the 2262 // Only the value field needs a write barrier, as the other values are in the
2252 // root set. 2263 // root set.
2253 __ RecordWriteField(a0, JSGeneratorObject::kResultValuePropertyOffset, 2264 __ RecordWriteField(a0, JSGeneratorObject::kResultValuePropertyOffset,
2254 a2, a3, kRAHasBeenSaved, kDontSaveFPRegs); 2265 a2, a3, kRAHasBeenSaved, kDontSaveFPRegs);
2255
2256 if (done) {
2257 // Exit all nested statements.
2258 NestedStatement* current = nesting_stack_;
2259 int stack_depth = 0;
2260 int context_length = 0;
2261 while (current != NULL) {
2262 current = current->Exit(&stack_depth, &context_length);
2263 }
2264 __ Drop(stack_depth);
2265 }
2266
2267 __ mov(result_register(), a0); 2266 __ mov(result_register(), a0);
2268 EmitReturnSequence();
2269
2270 __ bind(&gc_required);
2271 __ Push(Smi::FromInt(map->instance_size()));
2272 __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
2273 __ lw(context_register(),
2274 MemOperand(fp, StandardFrameConstants::kContextOffset));
2275 __ jmp(&allocated);
2276 } 2267 }
2277 2268
2278 2269
2279 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { 2270 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) {
2280 SetSourcePosition(prop->position()); 2271 SetSourcePosition(prop->position());
2281 Literal* key = prop->key()->AsLiteral(); 2272 Literal* key = prop->key()->AsLiteral();
2282 __ mov(a0, result_register()); 2273 __ mov(a0, result_register());
2283 __ li(a2, Operand(key->handle())); 2274 __ li(a2, Operand(key->handle()));
2284 // Call load IC. It has arguments receiver and property name a0 and a2. 2275 // Call load IC. It has arguments receiver and property name a0 and a2.
2285 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); 2276 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
(...skipping 2676 matching lines...) Expand 10 before | Expand all | Expand 10 after
4962 *context_length = 0; 4953 *context_length = 0;
4963 return previous_; 4954 return previous_;
4964 } 4955 }
4965 4956
4966 4957
4967 #undef __ 4958 #undef __
4968 4959
4969 } } // namespace v8::internal 4960 } } // namespace v8::internal
4970 4961
4971 #endif // V8_TARGET_ARCH_MIPS 4962 #endif // V8_TARGET_ARCH_MIPS
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