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

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

Issue 13704010: Generator objects can suspend (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Address comments; Refactor VisitYield 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/ast.h » ('j') | src/objects.h » ('J')
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 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 case NAMED_PROPERTY: 1915 case NAMED_PROPERTY:
1916 EmitNamedPropertyAssignment(expr); 1916 EmitNamedPropertyAssignment(expr);
1917 break; 1917 break;
1918 case KEYED_PROPERTY: 1918 case KEYED_PROPERTY:
1919 EmitKeyedPropertyAssignment(expr); 1919 EmitKeyedPropertyAssignment(expr);
1920 break; 1920 break;
1921 } 1921 }
1922 } 1922 }
1923 1923
1924 1924
1925 void FullCodeGenerator::VisitYield(Yield* expr) {
1926 Comment cmnt(masm_, "[ Yield");
1927 // Evaluate yielded value first; the initial iterator definition depends on
1928 // this. It stays on the stack while we update the iterator.
1929 VisitForStackValue(expr->expression());
1930
1931 switch (expr->yield_kind()) {
1932 case Yield::INITIAL:
1933 case Yield::SUSPEND: {
1934 VisitForStackValue(expr->generator_object());
1935 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
1936 __ ldr(context_register(),
1937 MemOperand(fp, StandardFrameConstants::kContextOffset));
1938
1939 Label resume;
1940 __ CompareRoot(result_register(), Heap::kTheHoleValueRootIndex);
1941 __ b(ne, &resume);
1942 __ pop(result_register());
1943 if (expr->yield_kind() == Yield::SUSPEND) {
1944 // TODO(wingo): Box into { value: VALUE, done: false }.
1945 }
1946 EmitReturnSequence();
1947
1948 __ bind(&resume);
1949 context()->Plug(result_register());
1950 break;
1951 }
1952
1953 case Yield::FINAL: {
1954 VisitForAccumulatorValue(expr->generator_object());
1955 // Mark this generator as closed by zeroing the continuation.
1956 __ mov(r1, Operand(Smi::FromInt(0)));
1957 __ str(r1, FieldMemOperand(result_register(),
1958 JSGeneratorObject::kContinuationOffset));
1959 __ pop(result_register());
1960 // TODO(wingo): Box into { value: VALUE, done: true }.
1961
1962 // Exit all nested statements.
1963 NestedStatement* current = nesting_stack_;
1964 int stack_depth = 0;
1965 int context_length = 0;
1966 while (current != NULL) {
1967 current = current->Exit(&stack_depth, &context_length);
1968 }
1969 __ Drop(stack_depth);
1970 EmitReturnSequence();
1971 break;
1972 }
1973
1974 case Yield::DELEGATING:
1975 UNIMPLEMENTED();
1976 }
1977 }
1978
1979
1925 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { 1980 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) {
1926 SetSourcePosition(prop->position()); 1981 SetSourcePosition(prop->position());
1927 Literal* key = prop->key()->AsLiteral(); 1982 Literal* key = prop->key()->AsLiteral();
1928 __ mov(r2, Operand(key->handle())); 1983 __ mov(r2, Operand(key->handle()));
1929 // Call load IC. It has arguments receiver and property name r0 and r2. 1984 // Call load IC. It has arguments receiver and property name r0 and r2.
1930 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); 1985 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
1931 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId()); 1986 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId());
1932 } 1987 }
1933 1988
1934 1989
(...skipping 2633 matching lines...) Expand 10 before | Expand all | Expand 10 after
4568 *context_length = 0; 4623 *context_length = 0;
4569 return previous_; 4624 return previous_;
4570 } 4625 }
4571 4626
4572 4627
4573 #undef __ 4628 #undef __
4574 4629
4575 } } // namespace v8::internal 4630 } } // namespace v8::internal
4576 4631
4577 #endif // V8_TARGET_ARCH_ARM 4632 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/ast.h » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698