OLD | NEW |
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 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1936 case Yield::INITIAL: | 1936 case Yield::INITIAL: |
1937 case Yield::SUSPEND: { | 1937 case Yield::SUSPEND: { |
1938 VisitForStackValue(expr->generator_object()); | 1938 VisitForStackValue(expr->generator_object()); |
1939 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 1939 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
1940 __ lw(context_register(), | 1940 __ lw(context_register(), |
1941 MemOperand(fp, StandardFrameConstants::kContextOffset)); | 1941 MemOperand(fp, StandardFrameConstants::kContextOffset)); |
1942 | 1942 |
1943 Label resume; | 1943 Label resume; |
1944 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | 1944 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
1945 __ Branch(&resume, ne, result_register(), Operand(at)); | 1945 __ Branch(&resume, ne, result_register(), Operand(at)); |
1946 __ pop(result_register()); | |
1947 if (expr->yield_kind() == Yield::SUSPEND) { | 1946 if (expr->yield_kind() == Yield::SUSPEND) { |
1948 // TODO(wingo): Box into { value: VALUE, done: false }. | 1947 EmitReturnIteratorResult(false); |
| 1948 } else { |
| 1949 __ pop(result_register()); |
| 1950 EmitReturnSequence(); |
1949 } | 1951 } |
1950 EmitReturnSequence(); | |
1951 | 1952 |
1952 __ bind(&resume); | 1953 __ bind(&resume); |
1953 context()->Plug(result_register()); | 1954 context()->Plug(result_register()); |
1954 break; | 1955 break; |
1955 } | 1956 } |
1956 | 1957 |
1957 case Yield::FINAL: { | 1958 case Yield::FINAL: { |
1958 VisitForAccumulatorValue(expr->generator_object()); | 1959 VisitForAccumulatorValue(expr->generator_object()); |
1959 __ li(a1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); | 1960 __ li(a1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); |
1960 __ sw(a1, FieldMemOperand(result_register(), | 1961 __ sw(a1, FieldMemOperand(result_register(), |
1961 JSGeneratorObject::kContinuationOffset)); | 1962 JSGeneratorObject::kContinuationOffset)); |
1962 __ pop(result_register()); | 1963 EmitReturnIteratorResult(true); |
1963 // TODO(wingo): Box into { value: VALUE, done: true }. | |
1964 | |
1965 // Exit all nested statements. | |
1966 NestedStatement* current = nesting_stack_; | |
1967 int stack_depth = 0; | |
1968 int context_length = 0; | |
1969 while (current != NULL) { | |
1970 current = current->Exit(&stack_depth, &context_length); | |
1971 } | |
1972 __ Drop(stack_depth); | |
1973 EmitReturnSequence(); | |
1974 break; | 1964 break; |
1975 } | 1965 } |
1976 | 1966 |
1977 case Yield::DELEGATING: | 1967 case Yield::DELEGATING: |
1978 UNIMPLEMENTED(); | 1968 UNIMPLEMENTED(); |
1979 } | 1969 } |
1980 } | 1970 } |
1981 | 1971 |
1982 | 1972 |
1983 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 1973 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2069 // Throw error if we attempt to operate on a running generator. | 2059 // Throw error if we attempt to operate on a running generator. |
2070 __ bind(&wrong_state); | 2060 __ bind(&wrong_state); |
2071 __ push(a1); | 2061 __ push(a1); |
2072 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1); | 2062 __ CallRuntime(Runtime::kThrowGeneratorStateError, 1); |
2073 | 2063 |
2074 __ bind(&done); | 2064 __ bind(&done); |
2075 context()->Plug(result_register()); | 2065 context()->Plug(result_register()); |
2076 } | 2066 } |
2077 | 2067 |
2078 | 2068 |
| 2069 void FullCodeGenerator::EmitReturnIteratorResult(bool done) { |
| 2070 Label gc_required; |
| 2071 Label allocated; |
| 2072 |
| 2073 Handle<Map> map(isolate()->native_context()->generator_result_map()); |
| 2074 |
| 2075 __ Allocate(map->instance_size(), a0, a2, a3, &gc_required, TAG_OBJECT); |
| 2076 |
| 2077 __ bind(&allocated); |
| 2078 __ li(a1, Operand(map)); |
| 2079 __ pop(a2); |
| 2080 __ li(a3, Operand(isolate()->factory()->ToBoolean(done))); |
| 2081 __ li(t0, Operand(isolate()->factory()->empty_fixed_array())); |
| 2082 ASSERT_EQ(map->instance_size(), 5 * kPointerSize); |
| 2083 __ sw(a1, FieldMemOperand(a0, HeapObject::kMapOffset)); |
| 2084 __ sw(t0, FieldMemOperand(a0, JSObject::kPropertiesOffset)); |
| 2085 __ sw(t0, FieldMemOperand(a0, JSObject::kElementsOffset)); |
| 2086 __ sw(a2, |
| 2087 FieldMemOperand(a0, JSGeneratorObject::kResultValuePropertyOffset)); |
| 2088 __ sw(a3, |
| 2089 FieldMemOperand(a0, JSGeneratorObject::kResultDonePropertyOffset)); |
| 2090 |
| 2091 // Only the value field needs a write barrier, as the other values are in the |
| 2092 // root set. |
| 2093 __ RecordWriteField(a0, JSGeneratorObject::kResultValuePropertyOffset, |
| 2094 a2, a3, kRAHasBeenSaved, kDontSaveFPRegs); |
| 2095 |
| 2096 if (done) { |
| 2097 // Exit all nested statements. |
| 2098 NestedStatement* current = nesting_stack_; |
| 2099 int stack_depth = 0; |
| 2100 int context_length = 0; |
| 2101 while (current != NULL) { |
| 2102 current = current->Exit(&stack_depth, &context_length); |
| 2103 } |
| 2104 __ Drop(stack_depth); |
| 2105 } |
| 2106 |
| 2107 __ mov(result_register(), a0); |
| 2108 EmitReturnSequence(); |
| 2109 |
| 2110 __ bind(&gc_required); |
| 2111 __ Push(Smi::FromInt(map->instance_size())); |
| 2112 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); |
| 2113 __ lw(context_register(), |
| 2114 MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2115 __ jmp(&allocated); |
| 2116 } |
| 2117 |
| 2118 |
2079 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { | 2119 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
2080 SetSourcePosition(prop->position()); | 2120 SetSourcePosition(prop->position()); |
2081 Literal* key = prop->key()->AsLiteral(); | 2121 Literal* key = prop->key()->AsLiteral(); |
2082 __ mov(a0, result_register()); | 2122 __ mov(a0, result_register()); |
2083 __ li(a2, Operand(key->handle())); | 2123 __ li(a2, Operand(key->handle())); |
2084 // Call load IC. It has arguments receiver and property name a0 and a2. | 2124 // Call load IC. It has arguments receiver and property name a0 and a2. |
2085 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); | 2125 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); |
2086 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId()); | 2126 CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId()); |
2087 } | 2127 } |
2088 | 2128 |
(...skipping 2626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4715 *context_length = 0; | 4755 *context_length = 0; |
4716 return previous_; | 4756 return previous_; |
4717 } | 4757 } |
4718 | 4758 |
4719 | 4759 |
4720 #undef __ | 4760 #undef __ |
4721 | 4761 |
4722 } } // namespace v8::internal | 4762 } } // namespace v8::internal |
4723 | 4763 |
4724 #endif // V8_TARGET_ARCH_MIPS | 4764 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |