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 <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #if V8_TARGET_ARCH_MIPS64 | 9 #if V8_TARGET_ARCH_MIPS64 |
10 | 10 |
(...skipping 3243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3254 | 3254 |
3255 void MacroAssembler::PopTryHandler() { | 3255 void MacroAssembler::PopTryHandler() { |
3256 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); | 3256 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); |
3257 pop(a1); | 3257 pop(a1); |
3258 Daddu(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize)); | 3258 Daddu(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize)); |
3259 li(at, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); | 3259 li(at, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); |
3260 sd(a1, MemOperand(at)); | 3260 sd(a1, MemOperand(at)); |
3261 } | 3261 } |
3262 | 3262 |
3263 | 3263 |
3264 void MacroAssembler::JumpToHandlerEntry() { | |
3265 // Compute the handler entry address and jump to it. The handler table is | |
3266 // a fixed array of (smi-tagged) code offsets. | |
3267 // v0 = exception, a1 = code object, a2 = state. | |
3268 ld(a3, FieldMemOperand(a1, Code::kHandlerTableOffset)); | |
3269 Daddu(a3, a3, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | |
3270 dsrl(a2, a2, StackHandler::kKindWidth); // Handler index. | |
3271 dsll(a2, a2, kPointerSizeLog2); | |
3272 Daddu(a2, a3, a2); | |
3273 ld(a2, MemOperand(a2)); // Smi-tagged offset. | |
3274 Daddu(a1, a1, Operand(Code::kHeaderSize - kHeapObjectTag)); // Code start. | |
3275 dsra32(t9, a2, 0); | |
3276 Daddu(t9, t9, a1); | |
3277 Jump(t9); // Jump. | |
3278 } | |
3279 | |
3280 | |
3281 void MacroAssembler::Throw(Register value) { | |
3282 // Adjust this code if not the case. | |
3283 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); | |
3284 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); | |
3285 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); | |
3286 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); | |
3287 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); | |
3288 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); | |
3289 | |
3290 // The exception is expected in v0. | |
3291 Move(v0, value); | |
3292 | |
3293 // Drop the stack pointer to the top of the top handler. | |
3294 li(a3, Operand(ExternalReference(Isolate::kHandlerAddress, | |
3295 isolate()))); | |
3296 ld(sp, MemOperand(a3)); | |
3297 | |
3298 // Restore the next handler. | |
3299 pop(a2); | |
3300 sd(a2, MemOperand(a3)); | |
3301 | |
3302 // Get the code object (a1) and state (a2). Restore the context and frame | |
3303 // pointer. | |
3304 MultiPop(a1.bit() | a2.bit() | cp.bit() | fp.bit()); | |
3305 | |
3306 // If the handler is a JS frame, restore the context to the frame. | |
3307 // (kind == ENTRY) == (fp == 0) == (cp == 0), so we could test either fp | |
3308 // or cp. | |
3309 Label done; | |
3310 Branch(&done, eq, cp, Operand(zero_reg)); | |
3311 sd(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
3312 bind(&done); | |
3313 | |
3314 JumpToHandlerEntry(); | |
3315 } | |
3316 | |
3317 | |
3318 void MacroAssembler::ThrowUncatchable(Register value) { | |
3319 // Adjust this code if not the case. | |
3320 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); | |
3321 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); | |
3322 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); | |
3323 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); | |
3324 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); | |
3325 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); | |
3326 | |
3327 // The exception is expected in v0. | |
3328 if (!value.is(v0)) { | |
3329 mov(v0, value); | |
3330 } | |
3331 // Drop the stack pointer to the top of the top stack handler. | |
3332 li(a3, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); | |
3333 ld(sp, MemOperand(a3)); | |
3334 | |
3335 // Unwind the handlers until the ENTRY handler is found. | |
3336 Label fetch_next, check_kind; | |
3337 jmp(&check_kind); | |
3338 bind(&fetch_next); | |
3339 ld(sp, MemOperand(sp, StackHandlerConstants::kNextOffset)); | |
3340 | |
3341 bind(&check_kind); | |
3342 STATIC_ASSERT(StackHandler::JS_ENTRY == 0); | |
3343 ld(a2, MemOperand(sp, StackHandlerConstants::kStateOffset)); | |
3344 And(a2, a2, Operand(StackHandler::KindField::kMask)); | |
3345 Branch(&fetch_next, ne, a2, Operand(zero_reg)); | |
3346 | |
3347 // Set the top handler address to next handler past the top ENTRY handler. | |
3348 pop(a2); | |
3349 sd(a2, MemOperand(a3)); | |
3350 | |
3351 // Get the code object (a1) and state (a2). Clear the context and frame | |
3352 // pointer (0 was saved in the handler). | |
3353 MultiPop(a1.bit() | a2.bit() | cp.bit() | fp.bit()); | |
3354 | |
3355 JumpToHandlerEntry(); | |
3356 } | |
3357 | |
3358 | |
3359 void MacroAssembler::Allocate(int object_size, | 3264 void MacroAssembler::Allocate(int object_size, |
3360 Register result, | 3265 Register result, |
3361 Register scratch1, | 3266 Register scratch1, |
3362 Register scratch2, | 3267 Register scratch2, |
3363 Label* gc_required, | 3268 Label* gc_required, |
3364 AllocationFlags flags) { | 3269 AllocationFlags flags) { |
3365 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); | 3270 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); |
3366 if (!FLAG_inline_new) { | 3271 if (!FLAG_inline_new) { |
3367 if (emit_debug_code()) { | 3272 if (emit_debug_code()) { |
3368 // Trash the registers to simulate an allocation failure. | 3273 // Trash the registers to simulate an allocation failure. |
(...skipping 2823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6192 } | 6097 } |
6193 if (mag.shift > 0) sra(result, result, mag.shift); | 6098 if (mag.shift > 0) sra(result, result, mag.shift); |
6194 srl(at, dividend, 31); | 6099 srl(at, dividend, 31); |
6195 Addu(result, result, Operand(at)); | 6100 Addu(result, result, Operand(at)); |
6196 } | 6101 } |
6197 | 6102 |
6198 | 6103 |
6199 } } // namespace v8::internal | 6104 } } // namespace v8::internal |
6200 | 6105 |
6201 #endif // V8_TARGET_ARCH_MIPS64 | 6106 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |