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

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

Issue 15210004: MIPS: Implement yield* (delegating yield) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after
1961 1961
1962 case Yield::FINAL: { 1962 case Yield::FINAL: {
1963 VisitForAccumulatorValue(expr->generator_object()); 1963 VisitForAccumulatorValue(expr->generator_object());
1964 __ li(a1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); 1964 __ li(a1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed)));
1965 __ sw(a1, FieldMemOperand(result_register(), 1965 __ sw(a1, FieldMemOperand(result_register(),
1966 JSGeneratorObject::kContinuationOffset)); 1966 JSGeneratorObject::kContinuationOffset));
1967 EmitReturnIteratorResult(true); 1967 EmitReturnIteratorResult(true);
1968 break; 1968 break;
1969 } 1969 }
1970 1970
1971 case Yield::DELEGATING: 1971 case Yield::DELEGATING: {
1972 UNIMPLEMENTED(); 1972 VisitForStackValue(expr->generator_object());
1973
1974 // Initial stack layout is as follows:
1975 // [sp + 1 * kPointerSize] iter
1976 // [sp + 0 * kPointerSize] g
1977
1978 Label l_catch, l_try, l_resume, l_send, l_call, l_loop;
1979 // Initial send value is undefined.
1980 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex);
1981 __ Branch(&l_send);
1982
1983 // catch (e) { receiver = iter; f = iter.throw; arg = e; goto l_call; }
1984 __ bind(&l_catch);
1985 __ mov(a0, v0);
1986 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos()));
1987 __ lw(a3, MemOperand(sp, 1 * kPointerSize)); // iter
1988 __ push(a3); // iter
1989 __ push(a0); // exception
1990 __ mov(a0, a3); // iter
1991 __ push(a0); // push LoadIC state
1992 __ LoadRoot(a2, Heap::kthrow_stringRootIndex); // "throw"
1993 Handle<Code> throw_ic = isolate()->builtins()->LoadIC_Initialize();
1994 CallIC(throw_ic); // iter.throw in a0
1995 __ mov(a0, v0);
1996 __ Addu(sp, sp, Operand(kPointerSize)); // drop LoadIC state
1997 __ jmp(&l_call);
1998
1999 // try { received = yield result.value }
2000 __ bind(&l_try);
2001 __ pop(a0); // result.value
2002 __ PushTryHandler(StackHandler::CATCH, expr->index());
2003 const int handler_size = StackHandlerConstants::kSize;
2004 __ push(a0); // result.value
2005 __ lw(a3, MemOperand(sp, (0 + 1) * kPointerSize + handler_size)); // g
2006 __ push(a3); // g
2007 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
2008 __ mov(a0, v0);
2009 __ lw(context_register(),
2010 MemOperand(fp, StandardFrameConstants::kContextOffset));
2011 __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
2012 __ Branch(&l_resume, ne, a0, Operand(at));
2013 EmitReturnIteratorResult(false);
2014 __ mov(a0, v0);
2015 __ bind(&l_resume); // received in a0
2016 __ PopTryHandler();
2017
2018 // receiver = iter; f = iter.send; arg = received;
2019 __ bind(&l_send);
2020 __ lw(a3, MemOperand(sp, 1 * kPointerSize)); // iter
2021 __ push(a3); // iter
2022 __ push(a0); // received
2023 __ mov(a0, a3); // iter
2024 __ push(a0); // push LoadIC state
2025 __ LoadRoot(a2, Heap::ksend_stringRootIndex); // "send"
2026 Handle<Code> send_ic = isolate()->builtins()->LoadIC_Initialize();
2027 CallIC(send_ic); // iter.send in a0
2028 __ mov(a0, v0);
2029 __ Addu(sp, sp, Operand(kPointerSize)); // drop LoadIC state
2030
2031 // result = f.call(receiver, arg);
2032 __ bind(&l_call);
2033 Label l_call_runtime;
2034 __ JumpIfSmi(a0, &l_call_runtime);
2035 __ GetObjectType(a0, a1, a1);
2036 __ Branch(&l_call_runtime, ne, a1, Operand(JS_FUNCTION_TYPE));
2037 __ mov(a1, a0);
2038 ParameterCount count(1);
2039 __ InvokeFunction(a1, count, CALL_FUNCTION,
2040 NullCallWrapper(), CALL_AS_METHOD);
2041 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
2042 __ jmp(&l_loop);
2043 __ bind(&l_call_runtime);
2044 __ push(a0);
2045 __ CallRuntime(Runtime::kCall, 3);
2046
2047 // val = result.value; if (!result.done) goto l_try;
2048 __ bind(&l_loop);
2049 __ mov(a0, v0);
2050 // result.value
2051 __ push(a0); // save result
2052 __ LoadRoot(a2, Heap::kvalue_stringRootIndex); // "value"
2053 Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize();
2054 CallIC(value_ic); // result.value in a0
2055 __ mov(a0, v0);
2056 __ pop(a1); // result
2057 __ push(a0); // result.value
2058 __ mov(a0, a1); // result
2059 __ push(a0); // push LoadIC state
2060 __ LoadRoot(a2, Heap::kdone_stringRootIndex); // "done"
2061 Handle<Code> done_ic = isolate()->builtins()->LoadIC_Initialize();
2062 CallIC(done_ic); // result.done in v0
2063 __ Addu(sp, sp, Operand(kPointerSize)); // drop LoadIC state
2064 ToBooleanStub stub(v0);
2065 __ CallStub(&stub);
2066 __ Branch(&l_try, eq, v0, Operand(zero_reg));
2067
2068 // result.value
2069 __ pop(v0); // result.value
2070 context()->DropAndPlug(2, v0); // drop iter and g
2071 break;
2072 }
1973 } 2073 }
1974 } 2074 }
1975 2075
1976 2076
1977 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, 2077 void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
1978 Expression *value, 2078 Expression *value,
1979 JSGeneratorObject::ResumeMode resume_mode) { 2079 JSGeneratorObject::ResumeMode resume_mode) {
1980 // The value stays in a0, and is ultimately read by the resumed generator, as 2080 // The value stays in a0, and is ultimately read by the resumed generator, as
1981 // if the CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. a1 2081 // if the CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. a1
1982 // will hold the generator object until the activation has been resumed. 2082 // will hold the generator object until the activation has been resumed.
(...skipping 2776 matching lines...) Expand 10 before | Expand all | Expand 10 after
4759 *context_length = 0; 4859 *context_length = 0;
4760 return previous_; 4860 return previous_;
4761 } 4861 }
4762 4862
4763 4863
4764 #undef __ 4864 #undef __
4765 4865
4766 } } // namespace v8::internal 4866 } } // namespace v8::internal
4767 4867
4768 #endif // V8_TARGET_ARCH_MIPS 4868 #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