OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
8 | 8 |
9 // Note on Mips implementation: | 9 // Note on Mips implementation: |
10 // | 10 // |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // o cp: our context | 108 // o cp: our context |
109 // o fp: our caller's frame pointer | 109 // o fp: our caller's frame pointer |
110 // o sp: stack pointer | 110 // o sp: stack pointer |
111 // o ra: return address | 111 // o ra: return address |
112 // | 112 // |
113 // The function builds a JS frame. Please see JavaScriptFrameConstants in | 113 // The function builds a JS frame. Please see JavaScriptFrameConstants in |
114 // frames-mips.h for its layout. | 114 // frames-mips.h for its layout. |
115 void FullCodeGenerator::Generate() { | 115 void FullCodeGenerator::Generate() { |
116 CompilationInfo* info = info_; | 116 CompilationInfo* info = info_; |
117 handler_table_ = | 117 handler_table_ = |
118 isolate()->factory()->NewFixedArray(function()->handler_count(), TENURED); | 118 Handle<HandlerTable>::cast(isolate()->factory()->NewFixedArray( |
| 119 HandlerTable::LengthForRange(function()->handler_count()), TENURED)); |
119 | 120 |
120 profiling_counter_ = isolate()->factory()->NewCell( | 121 profiling_counter_ = isolate()->factory()->NewCell( |
121 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); | 122 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); |
122 SetFunctionPosition(function()); | 123 SetFunctionPosition(function()); |
123 Comment cmnt(masm_, "[ function compiled by full code generator"); | 124 Comment cmnt(masm_, "[ function compiled by full code generator"); |
124 | 125 |
125 ProfileEntryHookStub::MaybeCallEntryHook(masm_); | 126 ProfileEntryHookStub::MaybeCallEntryHook(masm_); |
126 | 127 |
127 #ifdef DEBUG | 128 #ifdef DEBUG |
128 if (strlen(FLAG_stop_at) > 0 && | 129 if (strlen(FLAG_stop_at) > 0 && |
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2175 Label l_next, l_call; | 2176 Label l_next, l_call; |
2176 Register load_receiver = LoadDescriptor::ReceiverRegister(); | 2177 Register load_receiver = LoadDescriptor::ReceiverRegister(); |
2177 Register load_name = LoadDescriptor::NameRegister(); | 2178 Register load_name = LoadDescriptor::NameRegister(); |
2178 // Initial send value is undefined. | 2179 // Initial send value is undefined. |
2179 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); | 2180 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); |
2180 __ Branch(&l_next); | 2181 __ Branch(&l_next); |
2181 | 2182 |
2182 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } | 2183 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } |
2183 __ bind(&l_catch); | 2184 __ bind(&l_catch); |
2184 __ mov(a0, v0); | 2185 __ mov(a0, v0); |
2185 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos())); | |
2186 __ LoadRoot(a2, Heap::kthrow_stringRootIndex); // "throw" | 2186 __ LoadRoot(a2, Heap::kthrow_stringRootIndex); // "throw" |
2187 __ ld(a3, MemOperand(sp, 1 * kPointerSize)); // iter | 2187 __ ld(a3, MemOperand(sp, 1 * kPointerSize)); // iter |
2188 __ Push(a2, a3, a0); // "throw", iter, except | 2188 __ Push(a2, a3, a0); // "throw", iter, except |
2189 __ jmp(&l_call); | 2189 __ jmp(&l_call); |
2190 | 2190 |
2191 // try { received = %yield result } | 2191 // try { received = %yield result } |
2192 // Shuffle the received result above a try handler and yield it without | 2192 // Shuffle the received result above a try handler and yield it without |
2193 // re-boxing. | 2193 // re-boxing. |
2194 __ bind(&l_try); | 2194 __ bind(&l_try); |
2195 __ pop(a0); // result | 2195 __ pop(a0); // result |
2196 __ PushTryHandler(StackHandler::CATCH, expr->index()); | 2196 EnterTryBlock(expr->index(), &l_catch); |
2197 const int handler_size = StackHandlerConstants::kSize; | 2197 const int try_block_size = TryCatch::kElementCount * kPointerSize; |
2198 __ push(a0); // result | 2198 __ push(a0); // result |
2199 __ jmp(&l_suspend); | 2199 __ jmp(&l_suspend); |
2200 __ bind(&l_continuation); | 2200 __ bind(&l_continuation); |
2201 __ mov(a0, v0); | 2201 __ mov(a0, v0); |
2202 __ jmp(&l_resume); | 2202 __ jmp(&l_resume); |
2203 __ bind(&l_suspend); | 2203 __ bind(&l_suspend); |
2204 const int generator_object_depth = kPointerSize + handler_size; | 2204 const int generator_object_depth = kPointerSize + try_block_size; |
2205 __ ld(a0, MemOperand(sp, generator_object_depth)); | 2205 __ ld(a0, MemOperand(sp, generator_object_depth)); |
2206 __ push(a0); // g | 2206 __ push(a0); // g |
| 2207 __ Push(Smi::FromInt(expr->index())); // handler-index |
2207 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); | 2208 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); |
2208 __ li(a1, Operand(Smi::FromInt(l_continuation.pos()))); | 2209 __ li(a1, Operand(Smi::FromInt(l_continuation.pos()))); |
2209 __ sd(a1, FieldMemOperand(a0, JSGeneratorObject::kContinuationOffset)); | 2210 __ sd(a1, FieldMemOperand(a0, JSGeneratorObject::kContinuationOffset)); |
2210 __ sd(cp, FieldMemOperand(a0, JSGeneratorObject::kContextOffset)); | 2211 __ sd(cp, FieldMemOperand(a0, JSGeneratorObject::kContextOffset)); |
2211 __ mov(a1, cp); | 2212 __ mov(a1, cp); |
2212 __ RecordWriteField(a0, JSGeneratorObject::kContextOffset, a1, a2, | 2213 __ RecordWriteField(a0, JSGeneratorObject::kContextOffset, a1, a2, |
2213 kRAHasBeenSaved, kDontSaveFPRegs); | 2214 kRAHasBeenSaved, kDontSaveFPRegs); |
2214 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 2215 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2); |
2215 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2216 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2216 __ pop(v0); // result | 2217 __ pop(v0); // result |
2217 EmitReturnSequence(); | 2218 EmitReturnSequence(); |
2218 __ mov(a0, v0); | 2219 __ mov(a0, v0); |
2219 __ bind(&l_resume); // received in a0 | 2220 __ bind(&l_resume); // received in a0 |
2220 __ PopTryHandler(); | 2221 ExitTryBlock(expr->index()); |
2221 | 2222 |
2222 // receiver = iter; f = 'next'; arg = received; | 2223 // receiver = iter; f = 'next'; arg = received; |
2223 __ bind(&l_next); | 2224 __ bind(&l_next); |
2224 __ LoadRoot(load_name, Heap::knext_stringRootIndex); // "next" | 2225 __ LoadRoot(load_name, Heap::knext_stringRootIndex); // "next" |
2225 __ ld(a3, MemOperand(sp, 1 * kPointerSize)); // iter | 2226 __ ld(a3, MemOperand(sp, 1 * kPointerSize)); // iter |
2226 __ Push(load_name, a3, a0); // "next", iter, received | 2227 __ Push(load_name, a3, a0); // "next", iter, received |
2227 | 2228 |
2228 // result = receiver[f](arg); | 2229 // result = receiver[f](arg); |
2229 __ bind(&l_call); | 2230 __ bind(&l_call); |
2230 __ ld(load_receiver, MemOperand(sp, kPointerSize)); | 2231 __ ld(load_receiver, MemOperand(sp, kPointerSize)); |
(...skipping 3125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5356 __ pop(result_register()); | 5357 __ pop(result_register()); |
5357 | 5358 |
5358 __ SmiUntag(a1); | 5359 __ SmiUntag(a1); |
5359 __ Daddu(at, a1, Operand(masm_->CodeObject())); | 5360 __ Daddu(at, a1, Operand(masm_->CodeObject())); |
5360 __ Jump(at); | 5361 __ Jump(at); |
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, | |
5370 int* context_length) { | |
5371 // The macros used here must preserve the result register. | |
5372 | |
5373 // Because the handler block contains the context of the finally | |
5374 // code, we can restore it directly from there for the finally code | |
5375 // rather than iteratively unwinding contexts via their previous | |
5376 // links. | |
5377 __ Drop(*stack_depth); // Down to the handler block. | |
5378 if (*context_length > 0) { | |
5379 // Restore the context to its dedicated register and the stack. | |
5380 __ ld(cp, MemOperand(sp, StackHandlerConstants::kContextOffset)); | |
5381 __ sd(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
5382 } | |
5383 __ PopTryHandler(); | |
5384 __ Call(finally_entry_); | |
5385 | |
5386 *stack_depth = 0; | |
5387 *context_length = 0; | |
5388 return previous_; | |
5389 } | |
5390 | |
5391 | |
5392 #undef __ | |
5393 | |
5394 | 5367 |
5395 void BackEdgeTable::PatchAt(Code* unoptimized_code, | 5368 void BackEdgeTable::PatchAt(Code* unoptimized_code, |
5396 Address pc, | 5369 Address pc, |
5397 BackEdgeState target_state, | 5370 BackEdgeState target_state, |
5398 Code* replacement_code) { | 5371 Code* replacement_code) { |
5399 static const int kInstrSize = Assembler::kInstrSize; | 5372 static const int kInstrSize = Assembler::kInstrSize; |
5400 Address branch_address = pc - 8 * kInstrSize; | 5373 Address branch_address = pc - 8 * kInstrSize; |
5401 CodePatcher patcher(branch_address, 1); | 5374 CodePatcher patcher(branch_address, 1); |
5402 | 5375 |
5403 switch (target_state) { | 5376 switch (target_state) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5468 Assembler::target_address_at(pc_immediate_load_address)) == | 5441 Assembler::target_address_at(pc_immediate_load_address)) == |
5469 reinterpret_cast<uint64_t>( | 5442 reinterpret_cast<uint64_t>( |
5470 isolate->builtins()->OsrAfterStackCheck()->entry())); | 5443 isolate->builtins()->OsrAfterStackCheck()->entry())); |
5471 return OSR_AFTER_STACK_CHECK; | 5444 return OSR_AFTER_STACK_CHECK; |
5472 } | 5445 } |
5473 | 5446 |
5474 | 5447 |
5475 } } // namespace v8::internal | 5448 } } // namespace v8::internal |
5476 | 5449 |
5477 #endif // V8_TARGET_ARCH_MIPS64 | 5450 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |