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 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1346 void MacroAssembler::PushTryHandler(StackHandler::Kind kind, | 1346 void MacroAssembler::PushTryHandler(StackHandler::Kind kind, |
1347 int handler_index) { | 1347 int handler_index) { |
1348 // Adjust this code if not the case. | 1348 // Adjust this code if not the case. |
1349 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); | 1349 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); |
1350 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); | 1350 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); |
1351 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); | 1351 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); |
1352 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); | 1352 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); |
1353 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); | 1353 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); |
1354 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); | 1354 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); |
1355 | 1355 |
1356 // For the JSEntry handler, we must preserve r0-r4, r5-r7 are available. | 1356 // For the JSEntry handler, we must preserve r0-r4, r5-r6 are available. |
1357 // We will build up the handler from the bottom by pushing on the stack. | 1357 // We will build up the handler from the bottom by pushing on the stack. |
1358 // Set up the code object (r5) and the state (r6) for pushing. | 1358 // Set up the code object (r5) and the state (r6) for pushing. |
1359 unsigned state = | 1359 unsigned state = |
1360 StackHandler::IndexField::encode(handler_index) | | 1360 StackHandler::IndexField::encode(handler_index) | |
1361 StackHandler::KindField::encode(kind); | 1361 StackHandler::KindField::encode(kind); |
1362 mov(r5, Operand(CodeObject())); | 1362 mov(r5, Operand(CodeObject())); |
1363 mov(r6, Operand(state)); | 1363 mov(r6, Operand(state)); |
1364 | 1364 |
1365 // Push the frame pointer, context, state, and code object. | 1365 // Push the frame pointer, context, state, and code object. |
1366 if (kind == StackHandler::JS_ENTRY) { | 1366 if (kind == StackHandler::JS_ENTRY) { |
1367 mov(r7, Operand(Smi::FromInt(0))); // Indicates no context. | 1367 mov(cp, Operand(Smi::FromInt(0))); // Indicates no context. |
1368 mov(ip, Operand::Zero()); // NULL frame pointer. | 1368 mov(ip, Operand::Zero()); // NULL frame pointer. |
1369 stm(db_w, sp, r5.bit() | r6.bit() | r7.bit() | ip.bit()); | 1369 stm(db_w, sp, r5.bit() | r6.bit() | cp.bit() | ip.bit()); |
1370 } else { | 1370 } else { |
1371 stm(db_w, sp, r5.bit() | r6.bit() | cp.bit() | fp.bit()); | 1371 stm(db_w, sp, r5.bit() | r6.bit() | cp.bit() | fp.bit()); |
1372 } | 1372 } |
1373 | 1373 |
1374 // Link the current handler as the next handler. | 1374 // Link the current handler as the next handler. |
1375 mov(r6, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); | 1375 mov(r6, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); |
1376 ldr(r5, MemOperand(r6)); | 1376 ldr(r5, MemOperand(r6)); |
1377 push(r5); | 1377 push(r5); |
1378 // Set this new handler as the current one. | 1378 // Set this new handler as the current one. |
1379 str(sp, MemOperand(r6)); | 1379 str(sp, MemOperand(r6)); |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2299 ExternalReference next_address = | 2299 ExternalReference next_address = |
2300 ExternalReference::handle_scope_next_address(isolate()); | 2300 ExternalReference::handle_scope_next_address(isolate()); |
2301 const int kNextOffset = 0; | 2301 const int kNextOffset = 0; |
2302 const int kLimitOffset = AddressOffset( | 2302 const int kLimitOffset = AddressOffset( |
2303 ExternalReference::handle_scope_limit_address(isolate()), | 2303 ExternalReference::handle_scope_limit_address(isolate()), |
2304 next_address); | 2304 next_address); |
2305 const int kLevelOffset = AddressOffset( | 2305 const int kLevelOffset = AddressOffset( |
2306 ExternalReference::handle_scope_level_address(isolate()), | 2306 ExternalReference::handle_scope_level_address(isolate()), |
2307 next_address); | 2307 next_address); |
2308 | 2308 |
2309 ASSERT(!thunk_last_arg.is(r3)); | |
2310 | |
2309 // Allocate HandleScope in callee-save registers. | 2311 // Allocate HandleScope in callee-save registers. |
2310 mov(r7, Operand(next_address)); | 2312 mov(r3, Operand(next_address)); |
Rodolph Perfetta
2013/07/30 15:19:08
it looks like r9 is available here. It would save
rmcilroy
2013/07/30 17:12:37
I wasn't entirely sure on whether r9 was allowed h
| |
2311 ldr(r4, MemOperand(r7, kNextOffset)); | 2313 ldr(r4, MemOperand(r3, kNextOffset)); |
2312 ldr(r5, MemOperand(r7, kLimitOffset)); | 2314 ldr(r5, MemOperand(r3, kLimitOffset)); |
2313 ldr(r6, MemOperand(r7, kLevelOffset)); | 2315 ldr(r6, MemOperand(r3, kLevelOffset)); |
2314 add(r6, r6, Operand(1)); | 2316 add(r6, r6, Operand(1)); |
2315 str(r6, MemOperand(r7, kLevelOffset)); | 2317 str(r6, MemOperand(r3, kLevelOffset)); |
2316 | 2318 |
2317 if (FLAG_log_timer_events) { | 2319 if (FLAG_log_timer_events) { |
2318 FrameScope frame(this, StackFrame::MANUAL); | 2320 FrameScope frame(this, StackFrame::MANUAL); |
2319 PushSafepointRegisters(); | 2321 PushSafepointRegisters(); |
2320 PrepareCallCFunction(1, r0); | 2322 PrepareCallCFunction(1, r0); |
2321 mov(r0, Operand(ExternalReference::isolate_address(isolate()))); | 2323 mov(r0, Operand(ExternalReference::isolate_address(isolate()))); |
2322 CallCFunction(ExternalReference::log_enter_external_function(isolate()), 1); | 2324 CallCFunction(ExternalReference::log_enter_external_function(isolate()), 1); |
2323 PopSafepointRegisters(); | 2325 PopSafepointRegisters(); |
2324 } | 2326 } |
2325 | 2327 |
2326 ASSERT(!thunk_last_arg.is(r3)); | |
2327 Label profiler_disabled; | 2328 Label profiler_disabled; |
2328 Label end_profiler_check; | 2329 Label end_profiler_check; |
2329 bool* is_profiling_flag = | 2330 bool* is_profiling_flag = |
2330 isolate()->cpu_profiler()->is_profiling_address(); | 2331 isolate()->cpu_profiler()->is_profiling_address(); |
2331 STATIC_ASSERT(sizeof(*is_profiling_flag) == 1); | 2332 STATIC_ASSERT(sizeof(*is_profiling_flag) == 1); |
2332 mov(r3, Operand(reinterpret_cast<int32_t>(is_profiling_flag))); | 2333 mov(r3, Operand(reinterpret_cast<int32_t>(is_profiling_flag))); |
2333 ldrb(r3, MemOperand(r3, 0)); | 2334 ldrb(r3, MemOperand(r3, 0)); |
2334 cmp(r3, Operand(0)); | 2335 cmp(r3, Operand(0)); |
2335 b(eq, &profiler_disabled); | 2336 b(eq, &profiler_disabled); |
2336 | 2337 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2370 // derefernce returned value | 2371 // derefernce returned value |
2371 ldr(r0, MemOperand(r0)); | 2372 ldr(r0, MemOperand(r0)); |
2372 b(&return_value_loaded); | 2373 b(&return_value_loaded); |
2373 bind(&load_return_value); | 2374 bind(&load_return_value); |
2374 } | 2375 } |
2375 // load value from ReturnValue | 2376 // load value from ReturnValue |
2376 ldr(r0, MemOperand(fp, return_value_offset*kPointerSize)); | 2377 ldr(r0, MemOperand(fp, return_value_offset*kPointerSize)); |
2377 bind(&return_value_loaded); | 2378 bind(&return_value_loaded); |
2378 // No more valid handles (the result handle was the last one). Restore | 2379 // No more valid handles (the result handle was the last one). Restore |
2379 // previous handle scope. | 2380 // previous handle scope. |
2380 str(r4, MemOperand(r7, kNextOffset)); | 2381 mov(r3, Operand(next_address)); |
2382 str(r4, MemOperand(r3, kNextOffset)); | |
2381 if (emit_debug_code()) { | 2383 if (emit_debug_code()) { |
2382 ldr(r1, MemOperand(r7, kLevelOffset)); | 2384 ldr(r1, MemOperand(r3, kLevelOffset)); |
2383 cmp(r1, r6); | 2385 cmp(r1, r6); |
2384 Check(eq, "Unexpected level after return from api call"); | 2386 Check(eq, "Unexpected level after return from api call"); |
2385 } | 2387 } |
2386 sub(r6, r6, Operand(1)); | 2388 sub(r6, r6, Operand(1)); |
2387 str(r6, MemOperand(r7, kLevelOffset)); | 2389 str(r6, MemOperand(r3, kLevelOffset)); |
2388 ldr(ip, MemOperand(r7, kLimitOffset)); | 2390 ldr(ip, MemOperand(r3, kLimitOffset)); |
2389 cmp(r5, ip); | 2391 cmp(r5, ip); |
2390 b(ne, &delete_allocated_handles); | 2392 b(ne, &delete_allocated_handles); |
2391 | 2393 |
2392 // Check if the function scheduled an exception. | 2394 // Check if the function scheduled an exception. |
2393 bind(&leave_exit_frame); | 2395 bind(&leave_exit_frame); |
2394 LoadRoot(r4, Heap::kTheHoleValueRootIndex); | 2396 LoadRoot(r4, Heap::kTheHoleValueRootIndex); |
2395 mov(ip, Operand(ExternalReference::scheduled_exception_address(isolate()))); | 2397 mov(ip, Operand(ExternalReference::scheduled_exception_address(isolate()))); |
2396 ldr(r5, MemOperand(ip)); | 2398 ldr(r5, MemOperand(ip)); |
2397 cmp(r4, r5); | 2399 cmp(r4, r5); |
2398 b(ne, &promote_scheduled_exception); | 2400 b(ne, &promote_scheduled_exception); |
2399 | 2401 |
2400 // LeaveExitFrame expects unwind space to be in a register. | 2402 // LeaveExitFrame expects unwind space to be in a register. |
2401 mov(r4, Operand(stack_space)); | 2403 mov(r4, Operand(stack_space)); |
2402 LeaveExitFrame(false, r4); | 2404 LeaveExitFrame(false, r4); |
2403 mov(pc, lr); | 2405 mov(pc, lr); |
2404 | 2406 |
2405 bind(&promote_scheduled_exception); | 2407 bind(&promote_scheduled_exception); |
2406 TailCallExternalReference( | 2408 TailCallExternalReference( |
2407 ExternalReference(Runtime::kPromoteScheduledException, isolate()), | 2409 ExternalReference(Runtime::kPromoteScheduledException, isolate()), |
2408 0, | 2410 0, |
2409 1); | 2411 1); |
2410 | 2412 |
2411 // HandleScope limit has changed. Delete allocated extensions. | 2413 // HandleScope limit has changed. Delete allocated extensions. |
2412 bind(&delete_allocated_handles); | 2414 bind(&delete_allocated_handles); |
2413 str(r5, MemOperand(r7, kLimitOffset)); | 2415 str(r5, MemOperand(r3, kLimitOffset)); |
2414 mov(r4, r0); | 2416 mov(r4, r0); |
2415 PrepareCallCFunction(1, r5); | 2417 PrepareCallCFunction(1, r5); |
2416 mov(r0, Operand(ExternalReference::isolate_address(isolate()))); | 2418 mov(r0, Operand(ExternalReference::isolate_address(isolate()))); |
2417 CallCFunction( | 2419 CallCFunction( |
2418 ExternalReference::delete_handle_scope_extensions(isolate()), 1); | 2420 ExternalReference::delete_handle_scope_extensions(isolate()), 1); |
2419 mov(r0, r4); | 2421 mov(r0, r4); |
2420 jmp(&leave_exit_frame); | 2422 jmp(&leave_exit_frame); |
2421 } | 2423 } |
2422 | 2424 |
2423 | 2425 |
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3876 void CodePatcher::EmitCondition(Condition cond) { | 3878 void CodePatcher::EmitCondition(Condition cond) { |
3877 Instr instr = Assembler::instr_at(masm_.pc_); | 3879 Instr instr = Assembler::instr_at(masm_.pc_); |
3878 instr = (instr & ~kCondMask) | cond; | 3880 instr = (instr & ~kCondMask) | cond; |
3879 masm_.emit(instr); | 3881 masm_.emit(instr); |
3880 } | 3882 } |
3881 | 3883 |
3882 | 3884 |
3883 } } // namespace v8::internal | 3885 } } // namespace v8::internal |
3884 | 3886 |
3885 #endif // V8_TARGET_ARCH_ARM | 3887 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |