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_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
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 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 Register load_receiver = LoadDescriptor::ReceiverRegister(); | 2179 Register load_receiver = LoadDescriptor::ReceiverRegister(); |
2179 Register load_name = LoadDescriptor::NameRegister(); | 2180 Register load_name = LoadDescriptor::NameRegister(); |
2180 | 2181 |
2181 // Initial send value is undefined. | 2182 // Initial send value is undefined. |
2182 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); | 2183 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); |
2183 __ Branch(&l_next); | 2184 __ Branch(&l_next); |
2184 | 2185 |
2185 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } | 2186 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } |
2186 __ bind(&l_catch); | 2187 __ bind(&l_catch); |
2187 __ mov(a0, v0); | 2188 __ mov(a0, v0); |
2188 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos())); | |
2189 __ LoadRoot(load_name, Heap::kthrow_stringRootIndex); // "throw" | 2189 __ LoadRoot(load_name, Heap::kthrow_stringRootIndex); // "throw" |
2190 __ lw(a3, MemOperand(sp, 1 * kPointerSize)); // iter | 2190 __ lw(a3, MemOperand(sp, 1 * kPointerSize)); // iter |
2191 __ Push(load_name, a3, a0); // "throw", iter, except | 2191 __ Push(load_name, a3, a0); // "throw", iter, except |
2192 __ jmp(&l_call); | 2192 __ jmp(&l_call); |
2193 | 2193 |
2194 // try { received = %yield result } | 2194 // try { received = %yield result } |
2195 // Shuffle the received result above a try handler and yield it without | 2195 // Shuffle the received result above a try handler and yield it without |
2196 // re-boxing. | 2196 // re-boxing. |
2197 __ bind(&l_try); | 2197 __ bind(&l_try); |
2198 __ pop(a0); // result | 2198 __ pop(a0); // result |
2199 __ PushTryHandler(StackHandler::CATCH, expr->index()); | 2199 EnterTryBlock(expr->index(), &l_catch); |
2200 const int handler_size = StackHandlerConstants::kSize; | 2200 const int try_block_size = TryCatch::kElementCount * kPointerSize; |
2201 __ push(a0); // result | 2201 __ push(a0); // result |
2202 __ jmp(&l_suspend); | 2202 __ jmp(&l_suspend); |
2203 __ bind(&l_continuation); | 2203 __ bind(&l_continuation); |
2204 __ mov(a0, v0); | 2204 __ mov(a0, v0); |
2205 __ jmp(&l_resume); | 2205 __ jmp(&l_resume); |
2206 __ bind(&l_suspend); | 2206 __ bind(&l_suspend); |
2207 const int generator_object_depth = kPointerSize + handler_size; | 2207 const int generator_object_depth = kPointerSize + try_block_size; |
2208 __ lw(a0, MemOperand(sp, generator_object_depth)); | 2208 __ lw(a0, MemOperand(sp, generator_object_depth)); |
2209 __ push(a0); // g | 2209 __ push(a0); // g |
| 2210 __ Push(Smi::FromInt(expr->index())); // handler-index |
2210 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); | 2211 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); |
2211 __ li(a1, Operand(Smi::FromInt(l_continuation.pos()))); | 2212 __ li(a1, Operand(Smi::FromInt(l_continuation.pos()))); |
2212 __ sw(a1, FieldMemOperand(a0, JSGeneratorObject::kContinuationOffset)); | 2213 __ sw(a1, FieldMemOperand(a0, JSGeneratorObject::kContinuationOffset)); |
2213 __ sw(cp, FieldMemOperand(a0, JSGeneratorObject::kContextOffset)); | 2214 __ sw(cp, FieldMemOperand(a0, JSGeneratorObject::kContextOffset)); |
2214 __ mov(a1, cp); | 2215 __ mov(a1, cp); |
2215 __ RecordWriteField(a0, JSGeneratorObject::kContextOffset, a1, a2, | 2216 __ RecordWriteField(a0, JSGeneratorObject::kContextOffset, a1, a2, |
2216 kRAHasBeenSaved, kDontSaveFPRegs); | 2217 kRAHasBeenSaved, kDontSaveFPRegs); |
2217 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 2218 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2); |
2218 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2219 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2219 __ pop(v0); // result | 2220 __ pop(v0); // result |
2220 EmitReturnSequence(); | 2221 EmitReturnSequence(); |
2221 __ mov(a0, v0); | 2222 __ mov(a0, v0); |
2222 __ bind(&l_resume); // received in a0 | 2223 __ bind(&l_resume); // received in a0 |
2223 __ PopTryHandler(); | 2224 ExitTryBlock(expr->index()); |
2224 | 2225 |
2225 // receiver = iter; f = 'next'; arg = received; | 2226 // receiver = iter; f = 'next'; arg = received; |
2226 __ bind(&l_next); | 2227 __ bind(&l_next); |
2227 | 2228 |
2228 __ LoadRoot(load_name, Heap::knext_stringRootIndex); // "next" | 2229 __ LoadRoot(load_name, Heap::knext_stringRootIndex); // "next" |
2229 __ lw(a3, MemOperand(sp, 1 * kPointerSize)); // iter | 2230 __ lw(a3, MemOperand(sp, 1 * kPointerSize)); // iter |
2230 __ Push(load_name, a3, a0); // "next", iter, received | 2231 __ Push(load_name, a3, a0); // "next", iter, received |
2231 | 2232 |
2232 // result = receiver[f](arg); | 2233 // result = receiver[f](arg); |
2233 __ bind(&l_call); | 2234 __ bind(&l_call); |
(...skipping 3120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5354 __ pop(result_register()); | 5355 __ pop(result_register()); |
5355 DCHECK_EQ(1, kSmiTagSize + kSmiShiftSize); | 5356 DCHECK_EQ(1, kSmiTagSize + kSmiShiftSize); |
5356 __ sra(a1, a1, 1); // Un-smi-tag value. | 5357 __ sra(a1, a1, 1); // Un-smi-tag value. |
5357 __ Addu(at, a1, Operand(masm_->CodeObject())); | 5358 __ Addu(at, a1, Operand(masm_->CodeObject())); |
5358 __ Jump(at); | 5359 __ Jump(at); |
5359 } | 5360 } |
5360 | 5361 |
5361 | 5362 |
5362 #undef __ | 5363 #undef __ |
5363 | 5364 |
5364 #define __ ACCESS_MASM(masm()) | |
5365 | |
5366 FullCodeGenerator::NestedStatement* FullCodeGenerator::TryFinally::Exit( | |
5367 int* stack_depth, | |
5368 int* context_length) { | |
5369 // The macros used here must preserve the result register. | |
5370 | |
5371 // Because the handler block contains the context of the finally | |
5372 // code, we can restore it directly from there for the finally code | |
5373 // rather than iteratively unwinding contexts via their previous | |
5374 // links. | |
5375 __ Drop(*stack_depth); // Down to the handler block. | |
5376 if (*context_length > 0) { | |
5377 // Restore the context to its dedicated register and the stack. | |
5378 __ lw(cp, MemOperand(sp, StackHandlerConstants::kContextOffset)); | |
5379 __ sw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
5380 } | |
5381 __ PopTryHandler(); | |
5382 __ Call(finally_entry_); | |
5383 | |
5384 *stack_depth = 0; | |
5385 *context_length = 0; | |
5386 return previous_; | |
5387 } | |
5388 | |
5389 | |
5390 #undef __ | |
5391 | |
5392 | 5365 |
5393 void BackEdgeTable::PatchAt(Code* unoptimized_code, | 5366 void BackEdgeTable::PatchAt(Code* unoptimized_code, |
5394 Address pc, | 5367 Address pc, |
5395 BackEdgeState target_state, | 5368 BackEdgeState target_state, |
5396 Code* replacement_code) { | 5369 Code* replacement_code) { |
5397 static const int kInstrSize = Assembler::kInstrSize; | 5370 static const int kInstrSize = Assembler::kInstrSize; |
5398 Address branch_address = pc - 6 * kInstrSize; | 5371 Address branch_address = pc - 6 * kInstrSize; |
5399 CodePatcher patcher(branch_address, 1); | 5372 CodePatcher patcher(branch_address, 1); |
5400 | 5373 |
5401 switch (target_state) { | 5374 switch (target_state) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5462 Assembler::target_address_at(pc_immediate_load_address)) == | 5435 Assembler::target_address_at(pc_immediate_load_address)) == |
5463 reinterpret_cast<uint32_t>( | 5436 reinterpret_cast<uint32_t>( |
5464 isolate->builtins()->OsrAfterStackCheck()->entry())); | 5437 isolate->builtins()->OsrAfterStackCheck()->entry())); |
5465 return OSR_AFTER_STACK_CHECK; | 5438 return OSR_AFTER_STACK_CHECK; |
5466 } | 5439 } |
5467 | 5440 |
5468 | 5441 |
5469 } } // namespace v8::internal | 5442 } } // namespace v8::internal |
5470 | 5443 |
5471 #endif // V8_TARGET_ARCH_MIPS | 5444 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |