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

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

Issue 13864010: MIPS: Generators can resume (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 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 1962 matching lines...) Expand 10 before | Expand all | Expand 10 after
1973 EmitReturnSequence(); 1973 EmitReturnSequence();
1974 break; 1974 break;
1975 } 1975 }
1976 1976
1977 case Yield::DELEGATING: 1977 case Yield::DELEGATING:
1978 UNIMPLEMENTED(); 1978 UNIMPLEMENTED();
1979 } 1979 }
1980 } 1980 }
1981 1981
1982 1982
1983 void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
1984 Expression *value,
1985 JSGeneratorObject::ResumeMode resume_mode) {
1986 // The value stays in a0, and is ultimately read by the resumed generator, as
1987 // if the CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. a1
1988 // will hold the generator object until the activation has been resumed.
1989 VisitForStackValue(generator);
1990 VisitForAccumulatorValue(value);
1991 __ pop(a1);
1992
1993 // Check generator state.
1994 Label wrong_state, done;
1995 __ lw(a3, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset));
1996 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting <= 0);
1997 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed <= 0);
1998 __ Branch(&wrong_state, le, a3, Operand(zero_reg));
1999
2000 // Load suspended function and context.
2001 __ lw(cp, FieldMemOperand(a1, JSGeneratorObject::kContextOffset));
2002 __ lw(t0, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset));
2003
2004 // Push holes for arguments to generator function.
2005 __ lw(a3, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset));
2006 __ lw(a3,
2007 FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset));
2008 __ LoadRoot(a2, Heap::kTheHoleValueRootIndex);
2009 Label push_argument_holes;
2010 __ bind(&push_argument_holes);
2011 __ push(a2);
2012 __ Subu(a3, a3, Operand(1));
2013 __ Branch(&push_argument_holes, ge, a3, Operand(zero_reg));
2014
2015 // Enter a new JavaScript frame, and initialize its slots as they were when
2016 // the generator was suspended.
2017 Label push_frame, resume_frame;
2018 __ bind(&push_frame);
2019 __ Call(&resume_frame);
2020 __ jmp(&done);
2021 __ bind(&resume_frame);
2022 __ push(ra); // Return address.
2023 __ push(fp); // Caller's frame pointer.
2024 __ mov(fp, sp);
2025 __ push(cp); // Callee's context.
2026 __ push(t0); // Callee's JS Function.
2027
2028 // Load the operand stack size.
2029 __ lw(a3, FieldMemOperand(a1, JSGeneratorObject::kOperandStackOffset));
2030 __ lw(a3, FieldMemOperand(a3, FixedArray::kLengthOffset));
2031 __ SmiUntag(a3);
2032
2033 // If we are sending a value and there is no operand stack, we can jump back
2034 // in directly.
2035 if (resume_mode == JSGeneratorObject::SEND) {
2036 Label slow_resume;
2037 __ Branch(&slow_resume, ne, a3, Operand(zero_reg));
2038 __ lw(a3, FieldMemOperand(t0, JSFunction::kCodeEntryOffset));
2039 __ lw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset));
2040 __ SmiUntag(a2);
2041 __ Addu(a3, a3, Operand(a2));
2042 __ li(a2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)));
2043 __ sw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset));
2044 __ Jump(a3);
2045 __ bind(&slow_resume);
2046 }
2047
2048 // Otherwise, we push holes for the operand stack and call the runtime to fix
2049 // up the stack and the handlers.
2050 Label push_operand_holes, call_resume;
2051 __ bind(&push_operand_holes);
2052 __ Subu(a3, a3, Operand(1));
2053 __ Branch(&call_resume, lt, a3, Operand(zero_reg));
2054 __ push(a2);
2055 __ b(&push_operand_holes);
2056 __ bind(&call_resume);
2057 __ push(a1);
2058 __ push(result_register());
2059 __ Push(Smi::FromInt(resume_mode));
2060 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3);
2061 // Not reached: the runtime call returns elsewhere.
2062 __ stop("not-reached");
2063
2064 // Throw error if we attempt to operate on a running generator.
2065 __ bind(&wrong_state);
2066 __ push(a1);
2067 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1);
2068
2069 __ bind(&done);
2070 context()->Plug(result_register());
2071 }
2072
2073
1983 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { 2074 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) {
1984 SetSourcePosition(prop->position()); 2075 SetSourcePosition(prop->position());
1985 Literal* key = prop->key()->AsLiteral(); 2076 Literal* key = prop->key()->AsLiteral();
1986 __ mov(a0, result_register()); 2077 __ mov(a0, result_register());
1987 __ li(a2, Operand(key->handle())); 2078 __ li(a2, Operand(key->handle()));
1988 // Call load IC. It has arguments receiver and property name a0 and a2. 2079 // Call load IC. It has arguments receiver and property name a0 and a2.
1989 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); 2080 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
1990 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId()); 2081 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId());
1991 } 2082 }
1992 2083
(...skipping 2631 matching lines...) Expand 10 before | Expand all | Expand 10 after
4624 *context_length = 0; 4715 *context_length = 0;
4625 return previous_; 4716 return previous_;
4626 } 4717 }
4627 4718
4628 4719
4629 #undef __ 4720 #undef __
4630 4721
4631 } } // namespace v8::internal 4722 } } // namespace v8::internal
4632 4723
4633 #endif // V8_TARGET_ARCH_MIPS 4724 #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