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

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

Issue 13704010: Generator objects can suspend (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Use sentinel values for continuations 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 | « src/runtime.cc ('k') | test/mjsunit/harmony/generators-parsing.js » ('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 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 case NAMED_PROPERTY: 1900 case NAMED_PROPERTY:
1901 EmitNamedPropertyAssignment(expr); 1901 EmitNamedPropertyAssignment(expr);
1902 break; 1902 break;
1903 case KEYED_PROPERTY: 1903 case KEYED_PROPERTY:
1904 EmitKeyedPropertyAssignment(expr); 1904 EmitKeyedPropertyAssignment(expr);
1905 break; 1905 break;
1906 } 1906 }
1907 } 1907 }
1908 1908
1909 1909
1910 void FullCodeGenerator::VisitYield(Yield* expr) {
1911 Comment cmnt(masm_, "[ Yield");
1912 // Evaluate yielded value first; the initial iterator definition depends on
1913 // this. It stays on the stack while we update the iterator.
1914 VisitForStackValue(expr->expression());
1915
1916 switch (expr->yield_kind()) {
1917 case Yield::INITIAL:
1918 case Yield::SUSPEND: {
1919 VisitForStackValue(expr->generator_object());
1920 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
1921 __ movq(context_register(),
1922 Operand(rbp, StandardFrameConstants::kContextOffset));
1923
1924 Label resume;
1925 __ CompareRoot(result_register(), Heap::kTheHoleValueRootIndex);
1926 __ j(not_equal, &resume);
1927 __ pop(result_register());
1928 if (expr->yield_kind() == Yield::SUSPEND) {
1929 // TODO(wingo): Box into { value: VALUE, done: false }.
1930 }
1931 EmitReturnSequence();
1932
1933 __ bind(&resume);
1934 context()->Plug(result_register());
1935 break;
1936 }
1937
1938 case Yield::FINAL: {
1939 VisitForAccumulatorValue(expr->generator_object());
1940 __ Move(FieldOperand(result_register(),
1941 JSGeneratorObject::kContinuationOffset),
1942 Smi::FromInt(JSGeneratorObject::kGeneratorClosed));
1943 __ pop(result_register());
1944 // TODO(wingo): Box into { value: VALUE, done: true }.
1945
1946 // Exit all nested statements.
1947 NestedStatement* current = nesting_stack_;
1948 int stack_depth = 0;
1949 int context_length = 0;
1950 while (current != NULL) {
1951 current = current->Exit(&stack_depth, &context_length);
1952 }
1953 __ Drop(stack_depth);
1954 EmitReturnSequence();
1955 break;
1956 }
1957
1958 case Yield::DELEGATING:
1959 UNIMPLEMENTED();
1960 }
1961 }
1962
1963
1910 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { 1964 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) {
1911 SetSourcePosition(prop->position()); 1965 SetSourcePosition(prop->position());
1912 Literal* key = prop->key()->AsLiteral(); 1966 Literal* key = prop->key()->AsLiteral();
1913 __ Move(rcx, key->handle()); 1967 __ Move(rcx, key->handle());
1914 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); 1968 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
1915 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId()); 1969 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId());
1916 } 1970 }
1917 1971
1918 1972
1919 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { 1973 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) {
(...skipping 2639 matching lines...) Expand 10 before | Expand all | Expand 10 after
4559 *context_length = 0; 4613 *context_length = 0;
4560 return previous_; 4614 return previous_;
4561 } 4615 }
4562 4616
4563 4617
4564 #undef __ 4618 #undef __
4565 4619
4566 } } // namespace v8::internal 4620 } } // namespace v8::internal
4567 4621
4568 #endif // V8_TARGET_ARCH_X64 4622 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/harmony/generators-parsing.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698