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

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

Issue 14066016: Generators can resume (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Use Abort() instead of int3() 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
« no previous file with comments | « no previous file | src/full-codegen.h » ('j') | 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 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 EmitReturnSequence(); 1969 EmitReturnSequence();
1970 break; 1970 break;
1971 } 1971 }
1972 1972
1973 case Yield::DELEGATING: 1973 case Yield::DELEGATING:
1974 UNIMPLEMENTED(); 1974 UNIMPLEMENTED();
1975 } 1975 }
1976 } 1976 }
1977 1977
1978 1978
1979 void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
1980 Expression *value,
1981 JSGeneratorObject::ResumeMode resume_mode) {
1982 // The value stays in r0, and is ultimately read by the resumed generator, as
1983 // if the CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. r1
1984 // will hold the generator object until the activation has been resumed.
1985 VisitForStackValue(generator);
1986 VisitForAccumulatorValue(value);
1987 __ pop(r1);
1988
1989 // Check generator state.
1990 Label wrong_state, done;
1991 __ ldr(r3, FieldMemOperand(r1, JSGeneratorObject::kContinuationOffset));
1992 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting <= 0);
1993 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed <= 0);
1994 __ cmp(r3, Immediate(Smi::FromInt(0)));
1995 __ b(le, &wrong_state);
1996
1997 // Load suspended function and context.
1998 __ ldr(cp, FieldMemOperand(r1, JSGeneratorObject::kContextOffset));
1999 __ ldr(r4, FieldMemOperand(r1, JSGeneratorObject::kFunctionOffset));
2000
2001 // Push holes for arguments to generator function.
2002 __ ldr(r3, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset));
2003 __ ldr(r3,
2004 FieldMemOperand(r3, SharedFunctionInfo::kFormalParameterCountOffset));
2005 __ Move(r2, isolate()->factory()->the_hole_value());
2006 Label push_argument_holes;
2007 __ bind(&push_argument_holes);
2008 __ push(r2);
2009 __ sub(r3, r3, Immediate(1));
2010 __ b(vc, &push_argument_holes);
2011
2012 // Enter a new JavaScript frame, and initialize its slots as they were when
2013 // the generator was suspended.
2014 Label push_frame, resume_frame;
2015 __ bind(&push_frame);
2016 __ bl(&resume_frame);
2017 __ jmp(&done);
2018 __ bind(&resume_frame);
2019 __ push(fp); // Caller's frame pointer.
2020 __ mov(fp, sp);
2021 __ push(cp); // Callee's context.
2022 __ push(r4); // Callee's JS Function.
2023
2024 // Load the operand stack size.
2025 __ ldr(r3, FieldMemOperand(r1, JSGeneratorObject::kOperandStackOffset));
2026 __ ldr(r3, FieldMemOperand(r3, FixedArray::kLengthOffset));
2027 __ SmiUntag(r3);
2028
2029 // If we are sending a value and there is no operand stack, we can jump back
2030 // in directly.
2031 if (resume_mode == JSGeneratorObject::SEND) {
2032 Label slow_resume;
2033 __ cmp(r3, Immediate(0));
2034 __ b(ne, &slow_resume);
2035 __ ldr(r3, FieldMemOperand(r4, JSFunction::kCodeEntryOffset));
2036 __ ldr(r2, FieldMemOperand(r1, JSGeneratorObject::kContinuationOffset));
2037 __ SmiUntag(r2);
2038 __ add(r3, r3, r2);
2039 __ mov(r2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)));
2040 __ str(r2, FieldMemOperand(r1, JSGeneratorObject::kContinuationOffset));
2041 __ Jump(r3);
2042 __ bind(&slow_resume);
2043 }
2044
2045 // Otherwise, we push holes for the operand stack and call the runtime to fix
2046 // up the stack and the handlers.
2047 Label push_operand_holes, call_resume;
2048 __ bind(&push_operand_holes);
2049 __ sub(r3, r3, Immediate(1));
2050 __ b(vs, &call_resume);
2051 __ push(r2);
2052 __ b(&push_operand_holes);
2053 __ bind(&call_resume);
2054 __ push(r1);
2055 __ push(result_register());
2056 __ Push(Smi::FromInt(resume_mode));
2057 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3);
2058 // Not reached: the runtime call returns elsewhere.
2059 __ stop("not-reached");
2060
2061 // Throw error if we attempt to operate on a running generator.
2062 __ bind(&wrong_state);
2063 __ push(r1);
2064 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1);
2065
2066 __ bind(&done);
2067 context()->Plug(result_register());
2068 }
2069
2070
1979 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { 2071 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) {
1980 SetSourcePosition(prop->position()); 2072 SetSourcePosition(prop->position());
1981 Literal* key = prop->key()->AsLiteral(); 2073 Literal* key = prop->key()->AsLiteral();
1982 __ mov(r2, Operand(key->handle())); 2074 __ mov(r2, Operand(key->handle()));
1983 // Call load IC. It has arguments receiver and property name r0 and r2. 2075 // Call load IC. It has arguments receiver and property name r0 and r2.
1984 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); 2076 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
1985 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId()); 2077 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId());
1986 } 2078 }
1987 2079
1988 2080
(...skipping 2621 matching lines...) Expand 10 before | Expand all | Expand 10 after
4610 *context_length = 0; 4702 *context_length = 0;
4611 return previous_; 4703 return previous_;
4612 } 4704 }
4613 4705
4614 4706
4615 #undef __ 4707 #undef __
4616 4708
4617 } } // namespace v8::internal 4709 } } // namespace v8::internal
4618 4710
4619 #endif // V8_TARGET_ARCH_ARM 4711 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/full-codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698