OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 masm_(new MacroAssembler(NULL, buffer_size)), | 43 masm_(new MacroAssembler(NULL, buffer_size)), |
44 scope_(NULL), | 44 scope_(NULL), |
45 frame_(NULL), | 45 frame_(NULL), |
46 allocator_(NULL), | 46 allocator_(NULL), |
47 state_(NULL), | 47 state_(NULL), |
48 loop_nesting_(0), | 48 loop_nesting_(0), |
49 function_return_is_shadowed_(false), | 49 function_return_is_shadowed_(false), |
50 in_spilled_code_(false) { | 50 in_spilled_code_(false) { |
51 } | 51 } |
52 | 52 |
| 53 #define __ masm-> |
| 54 |
| 55 |
53 void CodeGenerator::DeclareGlobals(Handle<FixedArray> a) { | 56 void CodeGenerator::DeclareGlobals(Handle<FixedArray> a) { |
54 UNIMPLEMENTED(); | 57 UNIMPLEMENTED(); |
55 } | 58 } |
56 | 59 |
57 void CodeGenerator::GenCode(FunctionLiteral* a) { | 60 void CodeGenerator::GenCode(FunctionLiteral* a) { |
58 masm_->int3(); // UNIMPLEMENTED | 61 masm_->int3(); // UNIMPLEMENTED |
59 } | 62 } |
60 | 63 |
61 void CodeGenerator::GenerateFastCaseSwitchJumpTable(SwitchStatement* a, | 64 void CodeGenerator::GenerateFastCaseSwitchJumpTable(SwitchStatement* a, |
62 int b, | 65 int b, |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 225 |
223 void CodeGenerator::VisitThisFunction(ThisFunction* a) { | 226 void CodeGenerator::VisitThisFunction(ThisFunction* a) { |
224 UNIMPLEMENTED(); | 227 UNIMPLEMENTED(); |
225 } | 228 } |
226 | 229 |
227 | 230 |
228 void CEntryStub::GenerateBody(MacroAssembler* masm, bool is_debug_break) { | 231 void CEntryStub::GenerateBody(MacroAssembler* masm, bool is_debug_break) { |
229 masm->int3(); // TODO(X64): UNIMPLEMENTED. | 232 masm->int3(); // TODO(X64): UNIMPLEMENTED. |
230 } | 233 } |
231 | 234 |
232 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { | |
233 masm->int3(); // TODO(X64): UNIMPLEMENTED. | |
234 } | |
235 | |
236 | 235 |
| 236 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { |
| 237 Label invoke, exit; |
| 238 |
| 239 // Setup frame. |
| 240 __ push(rbp); |
| 241 __ movq(rbp, rsp); |
| 242 |
| 243 // Save callee-saved registers (X64 calling conventions). |
| 244 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; |
| 245 // Push something that is not an arguments adaptor. |
| 246 __ push(Immediate(ArgumentsAdaptorFrame::NON_SENTINEL)); |
| 247 __ push(Immediate(Smi::FromInt(marker))); // @ function offset |
| 248 __ push(r12); |
| 249 __ push(r13); |
| 250 __ push(r14); |
| 251 __ push(r15); |
| 252 __ push(rdi); |
| 253 __ push(rsi); |
| 254 __ push(rbx); |
| 255 // TODO(X64): Push XMM6-XMM15 (low 64 bits) as well, or make them |
| 256 // callee-save in JS code as well. |
| 257 |
| 258 // Save copies of the top frame descriptor on the stack. |
| 259 ExternalReference c_entry_fp(Top::k_c_entry_fp_address); |
| 260 __ load_rax(c_entry_fp); |
| 261 __ push(rax); |
| 262 |
| 263 // Call a faked try-block that does the invoke. |
| 264 __ call(&invoke); |
| 265 |
| 266 // Caught exception: Store result (exception) in the pending |
| 267 // exception field in the JSEnv and return a failure sentinel. |
| 268 ExternalReference pending_exception(Top::k_pending_exception_address); |
| 269 __ store_rax(pending_exception); |
| 270 __ movq(rax, Failure::Exception(), RelocInfo::NONE); |
| 271 __ jmp(&exit); |
| 272 |
| 273 // Invoke: Link this frame into the handler chain. |
| 274 __ bind(&invoke); |
| 275 __ PushTryHandler(IN_JS_ENTRY, JS_ENTRY_HANDLER); |
| 276 __ push(rax); // flush TOS |
| 277 |
| 278 // Clear any pending exceptions. |
| 279 __ load_rax(ExternalReference::the_hole_value_location()); |
| 280 __ store_rax(pending_exception); |
| 281 |
| 282 // Fake a receiver (NULL). |
| 283 __ push(Immediate(0)); // receiver |
| 284 |
| 285 // Invoke the function by calling through JS entry trampoline |
| 286 // builtin and pop the faked function when we return. We load the address |
| 287 // from an external reference instead of inlining the call target address |
| 288 // directly in the code, because the builtin stubs may not have been |
| 289 // generated yet at the time this code is generated. |
| 290 if (is_construct) { |
| 291 ExternalReference construct_entry(Builtins::JSConstructEntryTrampoline); |
| 292 __ load_rax(construct_entry); |
| 293 } else { |
| 294 ExternalReference entry(Builtins::JSEntryTrampoline); |
| 295 __ load_rax(entry); |
| 296 } |
| 297 __ call(FieldOperand(rax, Code::kHeaderSize)); |
| 298 |
| 299 // Unlink this frame from the handler chain. |
| 300 __ movq(kScratchRegister, ExternalReference(Top::k_handler_address)); |
| 301 __ pop(Operand(kScratchRegister, 0)); |
| 302 // Pop next_sp. |
| 303 __ add(rsp, Immediate(StackHandlerConstants::kSize - kPointerSize)); |
| 304 |
| 305 // Restore the top frame descriptor from the stack. |
| 306 __ bind(&exit); |
| 307 __ movq(kScratchRegister, ExternalReference(Top::k_c_entry_fp_address)); |
| 308 __ pop(Operand(kScratchRegister, 0)); |
| 309 |
| 310 // Restore callee-saved registers (X64 conventions). |
| 311 __ pop(rbx); |
| 312 __ pop(rsi); |
| 313 __ pop(rdi); |
| 314 __ pop(r15); |
| 315 __ pop(r14); |
| 316 __ pop(r13); |
| 317 __ pop(r12); |
| 318 __ add(rsp, Immediate(2 * kPointerSize)); // remove markers |
| 319 |
| 320 // Restore frame pointer and return. |
| 321 __ pop(rbp); |
| 322 __ ret(0); |
| 323 } |
| 324 |
| 325 |
| 326 #undef __ |
237 | 327 |
238 } } // namespace v8::internal | 328 } } // namespace v8::internal |
OLD | NEW |