OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 VisitStatementsAndSpill(body); | 282 VisitStatementsAndSpill(body); |
283 } | 283 } |
284 } | 284 } |
285 | 285 |
286 // Generate the return sequence if necessary. | 286 // Generate the return sequence if necessary. |
287 if (frame_ != NULL || function_return_.is_linked()) { | 287 if (frame_ != NULL || function_return_.is_linked()) { |
288 // exit | 288 // exit |
289 // r0: result | 289 // r0: result |
290 // sp: stack pointer | 290 // sp: stack pointer |
291 // fp: frame pointer | 291 // fp: frame pointer |
292 // pp: parameter pointer | |
293 // cp: callee's context | 292 // cp: callee's context |
294 __ mov(r0, Operand(Factory::undefined_value())); | 293 __ mov(r0, Operand(Factory::undefined_value())); |
295 | 294 |
296 function_return_.Bind(); | 295 function_return_.Bind(); |
297 if (FLAG_trace) { | 296 if (FLAG_trace) { |
298 // Push the return value on the stack as the parameter. | 297 // Push the return value on the stack as the parameter. |
299 // Runtime::TraceExit returns the parameter as it is. | 298 // Runtime::TraceExit returns the parameter as it is. |
300 frame_->EmitPush(r0); | 299 frame_->EmitPush(r0); |
301 frame_->CallRuntime(Runtime::kTraceExit, 1); | 300 frame_->CallRuntime(Runtime::kTraceExit, 1); |
302 } | 301 } |
(...skipping 4941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5244 ASSERT(((kFailureTag + 1) & kFailureTagMask) == 0); | 5243 ASSERT(((kFailureTag + 1) & kFailureTagMask) == 0); |
5245 // Lower 2 bits of r2 are 0 iff r0 has failure tag. | 5244 // Lower 2 bits of r2 are 0 iff r0 has failure tag. |
5246 __ add(r2, r0, Operand(1)); | 5245 __ add(r2, r0, Operand(1)); |
5247 __ tst(r2, Operand(kFailureTagMask)); | 5246 __ tst(r2, Operand(kFailureTagMask)); |
5248 __ b(eq, &failure_returned); | 5247 __ b(eq, &failure_returned); |
5249 | 5248 |
5250 // Exit C frame and return. | 5249 // Exit C frame and return. |
5251 // r0:r1: result | 5250 // r0:r1: result |
5252 // sp: stack pointer | 5251 // sp: stack pointer |
5253 // fp: frame pointer | 5252 // fp: frame pointer |
5254 // pp: caller's parameter pointer pp (restored as C callee-saved) | |
5255 __ LeaveExitFrame(frame_type); | 5253 __ LeaveExitFrame(frame_type); |
5256 | 5254 |
5257 // check if we should retry or throw exception | 5255 // check if we should retry or throw exception |
5258 Label retry; | 5256 Label retry; |
5259 __ bind(&failure_returned); | 5257 __ bind(&failure_returned); |
5260 ASSERT(Failure::RETRY_AFTER_GC == 0); | 5258 ASSERT(Failure::RETRY_AFTER_GC == 0); |
5261 __ tst(r0, Operand(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); | 5259 __ tst(r0, Operand(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); |
5262 __ b(eq, &retry); | 5260 __ b(eq, &retry); |
5263 | 5261 |
5264 Label continue_exception; | 5262 Label continue_exception; |
(...skipping 19 matching lines...) Expand all Loading... |
5284 | 5282 |
5285 __ bind(&retry); // pass last failure (r0) as parameter (r0) when retrying | 5283 __ bind(&retry); // pass last failure (r0) as parameter (r0) when retrying |
5286 } | 5284 } |
5287 | 5285 |
5288 | 5286 |
5289 void CEntryStub::GenerateBody(MacroAssembler* masm, bool is_debug_break) { | 5287 void CEntryStub::GenerateBody(MacroAssembler* masm, bool is_debug_break) { |
5290 // Called from JavaScript; parameters are on stack as if calling JS function | 5288 // Called from JavaScript; parameters are on stack as if calling JS function |
5291 // r0: number of arguments including receiver | 5289 // r0: number of arguments including receiver |
5292 // r1: pointer to builtin function | 5290 // r1: pointer to builtin function |
5293 // fp: frame pointer (restored after C call) | 5291 // fp: frame pointer (restored after C call) |
5294 // sp: stack pointer (restored as callee's pp after C call) | 5292 // sp: stack pointer (restored as callee's sp after C call) |
5295 // cp: current context (C callee-saved) | 5293 // cp: current context (C callee-saved) |
5296 // pp: caller's parameter pointer pp (C callee-saved) | |
5297 | 5294 |
5298 // NOTE: Invocations of builtins may return failure objects | 5295 // NOTE: Invocations of builtins may return failure objects |
5299 // instead of a proper result. The builtin entry handles | 5296 // instead of a proper result. The builtin entry handles |
5300 // this by performing a garbage collection and retrying the | 5297 // this by performing a garbage collection and retrying the |
5301 // builtin once. | 5298 // builtin once. |
5302 | 5299 |
5303 StackFrame::Type frame_type = is_debug_break | 5300 StackFrame::Type frame_type = is_debug_break |
5304 ? StackFrame::EXIT_DEBUG | 5301 ? StackFrame::EXIT_DEBUG |
5305 : StackFrame::EXIT; | 5302 : StackFrame::EXIT; |
5306 | 5303 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5357 // r0: code entry | 5354 // r0: code entry |
5358 // r1: function | 5355 // r1: function |
5359 // r2: receiver | 5356 // r2: receiver |
5360 // r3: argc | 5357 // r3: argc |
5361 // [sp+0]: argv | 5358 // [sp+0]: argv |
5362 | 5359 |
5363 Label invoke, exit; | 5360 Label invoke, exit; |
5364 | 5361 |
5365 // Called from C, so do not pop argc and args on exit (preserve sp) | 5362 // Called from C, so do not pop argc and args on exit (preserve sp) |
5366 // No need to save register-passed args | 5363 // No need to save register-passed args |
5367 // Save callee-saved registers (incl. cp, pp, and fp), sp, and lr | 5364 // Save callee-saved registers (incl. cp and fp), sp, and lr |
5368 __ stm(db_w, sp, kCalleeSaved | lr.bit()); | 5365 __ stm(db_w, sp, kCalleeSaved | lr.bit()); |
5369 | 5366 |
5370 // Get address of argv, see stm above. | 5367 // Get address of argv, see stm above. |
5371 // r0: code entry | 5368 // r0: code entry |
5372 // r1: function | 5369 // r1: function |
5373 // r2: receiver | 5370 // r2: receiver |
5374 // r3: argc | 5371 // r3: argc |
5375 __ add(r4, sp, Operand((kNumCalleeSaved + 1)*kPointerSize)); | 5372 __ add(r4, sp, Operand((kNumCalleeSaved + 1)*kPointerSize)); |
5376 __ ldr(r4, MemOperand(r4)); // argv | 5373 __ ldr(r4, MemOperand(r4)); // argv |
5377 | 5374 |
(...skipping 23 matching lines...) Expand all Loading... |
5401 // sets it to 0 to signal the existence of the JSEntry frame. | 5398 // sets it to 0 to signal the existence of the JSEntry frame. |
5402 __ mov(ip, Operand(ExternalReference(Top::k_pending_exception_address))); | 5399 __ mov(ip, Operand(ExternalReference(Top::k_pending_exception_address))); |
5403 __ str(r0, MemOperand(ip)); | 5400 __ str(r0, MemOperand(ip)); |
5404 __ mov(r0, Operand(reinterpret_cast<int32_t>(Failure::Exception()))); | 5401 __ mov(r0, Operand(reinterpret_cast<int32_t>(Failure::Exception()))); |
5405 __ b(&exit); | 5402 __ b(&exit); |
5406 | 5403 |
5407 // Invoke: Link this frame into the handler chain. | 5404 // Invoke: Link this frame into the handler chain. |
5408 __ bind(&invoke); | 5405 __ bind(&invoke); |
5409 // Must preserve r0-r4, r5-r7 are available. | 5406 // Must preserve r0-r4, r5-r7 are available. |
5410 __ PushTryHandler(IN_JS_ENTRY, JS_ENTRY_HANDLER); | 5407 __ PushTryHandler(IN_JS_ENTRY, JS_ENTRY_HANDLER); |
5411 // If an exception not caught by another handler occurs, this handler returns | 5408 // If an exception not caught by another handler occurs, this handler |
5412 // control to the code after the bl(&invoke) above, which restores all | 5409 // returns control to the code after the bl(&invoke) above, which |
5413 // kCalleeSaved registers (including cp, pp and fp) to their saved values | 5410 // restores all kCalleeSaved registers (including cp and fp) to their |
5414 // before returning a failure to C. | 5411 // saved values before returning a failure to C. |
5415 | 5412 |
5416 // Clear any pending exceptions. | 5413 // Clear any pending exceptions. |
5417 __ mov(ip, Operand(ExternalReference::the_hole_value_location())); | 5414 __ mov(ip, Operand(ExternalReference::the_hole_value_location())); |
5418 __ ldr(r5, MemOperand(ip)); | 5415 __ ldr(r5, MemOperand(ip)); |
5419 __ mov(ip, Operand(ExternalReference(Top::k_pending_exception_address))); | 5416 __ mov(ip, Operand(ExternalReference(Top::k_pending_exception_address))); |
5420 __ str(r5, MemOperand(ip)); | 5417 __ str(r5, MemOperand(ip)); |
5421 | 5418 |
5422 // Invoke the function by calling through JS entry trampoline builtin. | 5419 // Invoke the function by calling through JS entry trampoline builtin. |
5423 // Notice that we cannot store a reference to the trampoline code directly in | 5420 // Notice that we cannot store a reference to the trampoline code directly in |
5424 // this stub, because runtime stubs are not traversed when doing GC. | 5421 // this stub, because runtime stubs are not traversed when doing GC. |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5650 __ mov(r2, Operand(0)); | 5647 __ mov(r2, Operand(0)); |
5651 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); | 5648 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); |
5652 __ Jump(Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)), | 5649 __ Jump(Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)), |
5653 RelocInfo::CODE_TARGET); | 5650 RelocInfo::CODE_TARGET); |
5654 } | 5651 } |
5655 | 5652 |
5656 | 5653 |
5657 #undef __ | 5654 #undef __ |
5658 | 5655 |
5659 } } // namespace v8::internal | 5656 } } // namespace v8::internal |
OLD | NEW |