| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_PPC | 7 #if V8_TARGET_ARCH_PPC |
| 8 | 8 |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // o fp: our caller's frame pointer (aka r31) | 97 // o fp: our caller's frame pointer (aka r31) |
| 98 // o sp: stack pointer | 98 // o sp: stack pointer |
| 99 // o lr: return address | 99 // o lr: return address |
| 100 // o ip: our own function entry (required by the prologue) | 100 // o ip: our own function entry (required by the prologue) |
| 101 // | 101 // |
| 102 // The function builds a JS frame. Please see JavaScriptFrameConstants in | 102 // The function builds a JS frame. Please see JavaScriptFrameConstants in |
| 103 // frames-ppc.h for its layout. | 103 // frames-ppc.h for its layout. |
| 104 void FullCodeGenerator::Generate() { | 104 void FullCodeGenerator::Generate() { |
| 105 CompilationInfo* info = info_; | 105 CompilationInfo* info = info_; |
| 106 handler_table_ = | 106 handler_table_ = |
| 107 isolate()->factory()->NewFixedArray(function()->handler_count(), TENURED); | 107 Handle<HandlerTable>::cast(isolate()->factory()->NewFixedArray( |
| 108 HandlerTable::LengthForRange(function()->handler_count()), TENURED)); |
| 108 | 109 |
| 109 profiling_counter_ = isolate()->factory()->NewCell( | 110 profiling_counter_ = isolate()->factory()->NewCell( |
| 110 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); | 111 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); |
| 111 SetFunctionPosition(function()); | 112 SetFunctionPosition(function()); |
| 112 Comment cmnt(masm_, "[ function compiled by full code generator"); | 113 Comment cmnt(masm_, "[ function compiled by full code generator"); |
| 113 | 114 |
| 114 ProfileEntryHookStub::MaybeCallEntryHook(masm_); | 115 ProfileEntryHookStub::MaybeCallEntryHook(masm_); |
| 115 | 116 |
| 116 #ifdef DEBUG | 117 #ifdef DEBUG |
| 117 if (strlen(FLAG_stop_at) > 0 && | 118 if (strlen(FLAG_stop_at) > 0 && |
| (...skipping 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2136 Label l_next, l_call; | 2137 Label l_next, l_call; |
| 2137 Register load_receiver = LoadDescriptor::ReceiverRegister(); | 2138 Register load_receiver = LoadDescriptor::ReceiverRegister(); |
| 2138 Register load_name = LoadDescriptor::NameRegister(); | 2139 Register load_name = LoadDescriptor::NameRegister(); |
| 2139 | 2140 |
| 2140 // Initial send value is undefined. | 2141 // Initial send value is undefined. |
| 2141 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); | 2142 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); |
| 2142 __ b(&l_next); | 2143 __ b(&l_next); |
| 2143 | 2144 |
| 2144 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } | 2145 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } |
| 2145 __ bind(&l_catch); | 2146 __ bind(&l_catch); |
| 2146 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos())); | |
| 2147 __ LoadRoot(load_name, Heap::kthrow_stringRootIndex); // "throw" | 2147 __ LoadRoot(load_name, Heap::kthrow_stringRootIndex); // "throw" |
| 2148 __ LoadP(r6, MemOperand(sp, 1 * kPointerSize)); // iter | 2148 __ LoadP(r6, MemOperand(sp, 1 * kPointerSize)); // iter |
| 2149 __ Push(load_name, r6, r3); // "throw", iter, except | 2149 __ Push(load_name, r6, r3); // "throw", iter, except |
| 2150 __ b(&l_call); | 2150 __ b(&l_call); |
| 2151 | 2151 |
| 2152 // try { received = %yield result } | 2152 // try { received = %yield result } |
| 2153 // Shuffle the received result above a try handler and yield it without | 2153 // Shuffle the received result above a try handler and yield it without |
| 2154 // re-boxing. | 2154 // re-boxing. |
| 2155 __ bind(&l_try); | 2155 __ bind(&l_try); |
| 2156 __ pop(r3); // result | 2156 __ pop(r3); // result |
| 2157 __ PushTryHandler(StackHandler::CATCH, expr->index()); | 2157 EnterTryBlock(expr->index(), &l_catch); |
| 2158 const int handler_size = StackHandlerConstants::kSize; | 2158 const int try_block_size = TryCatch::kElementCount * kPointerSize; |
| 2159 __ push(r3); // result | 2159 __ push(r3); // result |
| 2160 __ b(&l_suspend); | 2160 __ b(&l_suspend); |
| 2161 __ bind(&l_continuation); | 2161 __ bind(&l_continuation); |
| 2162 __ b(&l_resume); | 2162 __ b(&l_resume); |
| 2163 __ bind(&l_suspend); | 2163 __ bind(&l_suspend); |
| 2164 const int generator_object_depth = kPointerSize + handler_size; | 2164 const int generator_object_depth = kPointerSize + try_block_size; |
| 2165 __ LoadP(r3, MemOperand(sp, generator_object_depth)); | 2165 __ LoadP(r3, MemOperand(sp, generator_object_depth)); |
| 2166 __ push(r3); // g | 2166 __ push(r3); // g |
| 2167 __ Push(Smi::FromInt(expr->index())); // handler-index |
| 2167 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); | 2168 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); |
| 2168 __ LoadSmiLiteral(r4, Smi::FromInt(l_continuation.pos())); | 2169 __ LoadSmiLiteral(r4, Smi::FromInt(l_continuation.pos())); |
| 2169 __ StoreP(r4, FieldMemOperand(r3, JSGeneratorObject::kContinuationOffset), | 2170 __ StoreP(r4, FieldMemOperand(r3, JSGeneratorObject::kContinuationOffset), |
| 2170 r0); | 2171 r0); |
| 2171 __ StoreP(cp, FieldMemOperand(r3, JSGeneratorObject::kContextOffset), r0); | 2172 __ StoreP(cp, FieldMemOperand(r3, JSGeneratorObject::kContextOffset), r0); |
| 2172 __ mr(r4, cp); | 2173 __ mr(r4, cp); |
| 2173 __ RecordWriteField(r3, JSGeneratorObject::kContextOffset, r4, r5, | 2174 __ RecordWriteField(r3, JSGeneratorObject::kContextOffset, r4, r5, |
| 2174 kLRHasBeenSaved, kDontSaveFPRegs); | 2175 kLRHasBeenSaved, kDontSaveFPRegs); |
| 2175 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 2176 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2); |
| 2176 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2177 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2177 __ pop(r3); // result | 2178 __ pop(r3); // result |
| 2178 EmitReturnSequence(); | 2179 EmitReturnSequence(); |
| 2179 __ bind(&l_resume); // received in r3 | 2180 __ bind(&l_resume); // received in r3 |
| 2180 __ PopTryHandler(); | 2181 ExitTryBlock(expr->index()); |
| 2181 | 2182 |
| 2182 // receiver = iter; f = 'next'; arg = received; | 2183 // receiver = iter; f = 'next'; arg = received; |
| 2183 __ bind(&l_next); | 2184 __ bind(&l_next); |
| 2184 | 2185 |
| 2185 __ LoadRoot(load_name, Heap::knext_stringRootIndex); // "next" | 2186 __ LoadRoot(load_name, Heap::knext_stringRootIndex); // "next" |
| 2186 __ LoadP(r6, MemOperand(sp, 1 * kPointerSize)); // iter | 2187 __ LoadP(r6, MemOperand(sp, 1 * kPointerSize)); // iter |
| 2187 __ Push(load_name, r6, r3); // "next", iter, received | 2188 __ Push(load_name, r6, r3); // "next", iter, received |
| 2188 | 2189 |
| 2189 // result = receiver[f](arg); | 2190 // result = receiver[f](arg); |
| 2190 __ bind(&l_call); | 2191 __ bind(&l_call); |
| (...skipping 3165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5356 __ SmiUntag(r4); | 5357 __ SmiUntag(r4); |
| 5357 __ mov(ip, Operand(masm_->CodeObject())); | 5358 __ mov(ip, Operand(masm_->CodeObject())); |
| 5358 __ add(ip, ip, r4); | 5359 __ add(ip, ip, r4); |
| 5359 __ mtctr(ip); | 5360 __ mtctr(ip); |
| 5360 __ bctr(); | 5361 __ bctr(); |
| 5361 } | 5362 } |
| 5362 | 5363 |
| 5363 | 5364 |
| 5364 #undef __ | 5365 #undef __ |
| 5365 | 5366 |
| 5366 #define __ ACCESS_MASM(masm()) | |
| 5367 | |
| 5368 FullCodeGenerator::NestedStatement* FullCodeGenerator::TryFinally::Exit( | |
| 5369 int* stack_depth, int* context_length) { | |
| 5370 // The macros used here must preserve the result register. | |
| 5371 | |
| 5372 // Because the handler block contains the context of the finally | |
| 5373 // code, we can restore it directly from there for the finally code | |
| 5374 // rather than iteratively unwinding contexts via their previous | |
| 5375 // links. | |
| 5376 __ Drop(*stack_depth); // Down to the handler block. | |
| 5377 if (*context_length > 0) { | |
| 5378 // Restore the context to its dedicated register and the stack. | |
| 5379 __ LoadP(cp, MemOperand(sp, StackHandlerConstants::kContextOffset)); | |
| 5380 __ StoreP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
| 5381 } | |
| 5382 __ PopTryHandler(); | |
| 5383 __ b(finally_entry_, SetLK); | |
| 5384 | |
| 5385 *stack_depth = 0; | |
| 5386 *context_length = 0; | |
| 5387 return previous_; | |
| 5388 } | |
| 5389 | |
| 5390 #undef __ | |
| 5391 | |
| 5392 | 5367 |
| 5393 void BackEdgeTable::PatchAt(Code* unoptimized_code, Address pc, | 5368 void BackEdgeTable::PatchAt(Code* unoptimized_code, Address pc, |
| 5394 BackEdgeState target_state, | 5369 BackEdgeState target_state, |
| 5395 Code* replacement_code) { | 5370 Code* replacement_code) { |
| 5396 Address mov_address = Assembler::target_address_from_return_address(pc); | 5371 Address mov_address = Assembler::target_address_from_return_address(pc); |
| 5397 Address cmp_address = mov_address - 2 * Assembler::kInstrSize; | 5372 Address cmp_address = mov_address - 2 * Assembler::kInstrSize; |
| 5398 CodePatcher patcher(cmp_address, 1); | 5373 CodePatcher patcher(cmp_address, 1); |
| 5399 | 5374 |
| 5400 switch (target_state) { | 5375 switch (target_state) { |
| 5401 case INTERRUPT: { | 5376 case INTERRUPT: { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5454 return ON_STACK_REPLACEMENT; | 5429 return ON_STACK_REPLACEMENT; |
| 5455 } | 5430 } |
| 5456 | 5431 |
| 5457 DCHECK(interrupt_address == | 5432 DCHECK(interrupt_address == |
| 5458 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5433 isolate->builtins()->OsrAfterStackCheck()->entry()); |
| 5459 return OSR_AFTER_STACK_CHECK; | 5434 return OSR_AFTER_STACK_CHECK; |
| 5460 } | 5435 } |
| 5461 } | 5436 } |
| 5462 } // namespace v8::internal | 5437 } // namespace v8::internal |
| 5463 #endif // V8_TARGET_ARCH_PPC | 5438 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |