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

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

Issue 13870007: Generators return boxed values (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Fix x64 thinko; add result map test 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
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('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 1921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 case Yield::INITIAL: 1932 case Yield::INITIAL:
1933 case Yield::SUSPEND: { 1933 case Yield::SUSPEND: {
1934 VisitForStackValue(expr->generator_object()); 1934 VisitForStackValue(expr->generator_object());
1935 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); 1935 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
1936 __ ldr(context_register(), 1936 __ ldr(context_register(),
1937 MemOperand(fp, StandardFrameConstants::kContextOffset)); 1937 MemOperand(fp, StandardFrameConstants::kContextOffset));
1938 1938
1939 Label resume; 1939 Label resume;
1940 __ CompareRoot(result_register(), Heap::kTheHoleValueRootIndex); 1940 __ CompareRoot(result_register(), Heap::kTheHoleValueRootIndex);
1941 __ b(ne, &resume); 1941 __ b(ne, &resume);
1942 __ pop(result_register());
1943 if (expr->yield_kind() == Yield::SUSPEND) { 1942 if (expr->yield_kind() == Yield::SUSPEND) {
1944 // TODO(wingo): Box into { value: VALUE, done: false }. 1943 EmitReturnIteratorResult(false);
1944 } else {
1945 __ pop(result_register());
1946 EmitReturnSequence();
1945 } 1947 }
1946 EmitReturnSequence();
1947 1948
1948 __ bind(&resume); 1949 __ bind(&resume);
1949 context()->Plug(result_register()); 1950 context()->Plug(result_register());
1950 break; 1951 break;
1951 } 1952 }
1952 1953
1953 case Yield::FINAL: { 1954 case Yield::FINAL: {
1954 VisitForAccumulatorValue(expr->generator_object()); 1955 VisitForAccumulatorValue(expr->generator_object());
1955 __ mov(r1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); 1956 __ mov(r1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed)));
1956 __ str(r1, FieldMemOperand(result_register(), 1957 __ str(r1, FieldMemOperand(result_register(),
1957 JSGeneratorObject::kContinuationOffset)); 1958 JSGeneratorObject::kContinuationOffset));
1958 __ pop(result_register()); 1959 EmitReturnIteratorResult(true);
1959 // TODO(wingo): Box into { value: VALUE, done: true }.
1960
1961 // Exit all nested statements.
1962 NestedStatement* current = nesting_stack_;
1963 int stack_depth = 0;
1964 int context_length = 0;
1965 while (current != NULL) {
1966 current = current->Exit(&stack_depth, &context_length);
1967 }
1968 __ Drop(stack_depth);
1969 EmitReturnSequence();
1970 break; 1960 break;
1971 } 1961 }
1972 1962
1973 case Yield::DELEGATING: 1963 case Yield::DELEGATING:
1974 UNIMPLEMENTED(); 1964 UNIMPLEMENTED();
1975 } 1965 }
1976 } 1966 }
1977 1967
1978 1968
1979 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, 1969 void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2067 // Throw error if we attempt to operate on a running generator. 2057 // Throw error if we attempt to operate on a running generator.
2068 __ bind(&wrong_state); 2058 __ bind(&wrong_state);
2069 __ push(r1); 2059 __ push(r1);
2070 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1); 2060 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1);
2071 2061
2072 __ bind(&done); 2062 __ bind(&done);
2073 context()->Plug(result_register()); 2063 context()->Plug(result_register());
2074 } 2064 }
2075 2065
2076 2066
2067 void FullCodeGenerator::EmitReturnIteratorResult(bool done) {
2068 Label gc_required;
2069 Label allocated;
2070
2071 Handle<Map> map(isolate()->native_context()->generator_result_map());
2072
2073 __ Allocate(map->instance_size(), r0, r2, r3, &gc_required, TAG_OBJECT);
2074
2075 __ bind(&allocated);
2076 __ mov(r1, Operand(map));
2077 __ pop(r2);
2078 __ mov(r3, Operand(isolate()->factory()->ToBoolean(done)));
2079 __ mov(r4, Operand(isolate()->factory()->empty_fixed_array()));
2080 ASSERT_EQ(map->instance_size(), 5 * kPointerSize);
2081 __ str(r1, FieldMemOperand(r0, HeapObject::kMapOffset));
2082 __ str(r4, FieldMemOperand(r0, JSObject::kPropertiesOffset));
2083 __ str(r4, FieldMemOperand(r0, JSObject::kElementsOffset));
2084 __ str(r2,
2085 FieldMemOperand(r0, JSGeneratorObject::kResultValuePropertyOffset));
2086 __ str(r3,
2087 FieldMemOperand(r0, JSGeneratorObject::kResultDonePropertyOffset));
2088
2089 // Only the value field needs a write barrier, as the other values are in the
2090 // root set.
2091 __ RecordWriteField(r0, JSGeneratorObject::kResultValuePropertyOffset,
2092 r2, r3, kLRHasBeenSaved, kDontSaveFPRegs);
2093
2094 if (done) {
2095 // Exit all nested statements.
2096 NestedStatement* current = nesting_stack_;
2097 int stack_depth = 0;
2098 int context_length = 0;
2099 while (current != NULL) {
2100 current = current->Exit(&stack_depth, &context_length);
2101 }
2102 __ Drop(stack_depth);
2103 }
2104
2105 EmitReturnSequence();
2106
2107 __ bind(&gc_required);
2108 __ Push(Smi::FromInt(map->instance_size()));
2109 __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
2110 __ ldr(context_register(),
2111 MemOperand(fp, StandardFrameConstants::kContextOffset));
2112 __ jmp(&allocated);
2113 }
2114
2115
2077 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { 2116 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) {
2078 SetSourcePosition(prop->position()); 2117 SetSourcePosition(prop->position());
2079 Literal* key = prop->key()->AsLiteral(); 2118 Literal* key = prop->key()->AsLiteral();
2080 __ mov(r2, Operand(key->handle())); 2119 __ mov(r2, Operand(key->handle()));
2081 // Call load IC. It has arguments receiver and property name r0 and r2. 2120 // Call load IC. It has arguments receiver and property name r0 and r2.
2082 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); 2121 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
2083 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId()); 2122 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId());
2084 } 2123 }
2085 2124
2086 2125
(...skipping 2615 matching lines...) Expand 10 before | Expand all | Expand 10 after
4702 *context_length = 0; 4741 *context_length = 0;
4703 return previous_; 4742 return previous_;
4704 } 4743 }
4705 4744
4706 4745
4707 #undef __ 4746 #undef __
4708 4747
4709 } } // namespace v8::internal 4748 } } // namespace v8::internal
4710 4749
4711 #endif // V8_TARGET_ARCH_ARM 4750 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698