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 24 matching lines...) Expand all Loading... |
35 namespace internal { | 35 namespace internal { |
36 | 36 |
37 MacroAssembler::MacroAssembler(void* buffer, int size) | 37 MacroAssembler::MacroAssembler(void* buffer, int size) |
38 : Assembler(buffer, size), | 38 : Assembler(buffer, size), |
39 unresolved_(0), | 39 unresolved_(0), |
40 generating_stub_(false), | 40 generating_stub_(false), |
41 allow_stub_calls_(true), | 41 allow_stub_calls_(true), |
42 code_object_(Heap::undefined_value()) { | 42 code_object_(Heap::undefined_value()) { |
43 } | 43 } |
44 | 44 |
| 45 |
45 void MacroAssembler::TailCallRuntime(ExternalReference const& a, int b) { | 46 void MacroAssembler::TailCallRuntime(ExternalReference const& a, int b) { |
46 UNIMPLEMENTED(); | 47 UNIMPLEMENTED(); |
47 } | 48 } |
48 | 49 |
49 | 50 |
50 void MacroAssembler::Set(Register dst, int64_t x) { | 51 void MacroAssembler::Set(Register dst, int64_t x) { |
51 if (is_int32(x)) { | 52 if (is_int32(x)) { |
52 movq(dst, Immediate(x)); | 53 movq(dst, Immediate(x)); |
53 } else if (is_uint32(x)) { | 54 } else if (is_uint32(x)) { |
54 movl(dst, Immediate(x)); | 55 movl(dst, Immediate(x)); |
55 } else { | 56 } else { |
56 movq(dst, x, RelocInfo::NONE); | 57 movq(dst, x, RelocInfo::NONE); |
57 } | 58 } |
58 } | 59 } |
59 | 60 |
60 | 61 |
61 void MacroAssembler::Set(const Operand& dst, int64_t x) { | 62 void MacroAssembler::Set(const Operand& dst, int64_t x) { |
62 if (is_int32(x)) { | 63 if (is_int32(x)) { |
63 movq(kScratchRegister, Immediate(x)); | 64 movq(kScratchRegister, Immediate(x)); |
64 } else if (is_uint32(x)) { | 65 } else if (is_uint32(x)) { |
65 movl(kScratchRegister, Immediate(x)); | 66 movl(kScratchRegister, Immediate(x)); |
66 } else { | 67 } else { |
67 movq(kScratchRegister, x, RelocInfo::NONE); | 68 movq(kScratchRegister, x, RelocInfo::NONE); |
68 } | 69 } |
69 movq(dst, kScratchRegister); | 70 movq(dst, kScratchRegister); |
70 } | 71 } |
71 | 72 |
72 | 73 |
| 74 void MacroAssembler::PushTryHandler(CodeLocation try_location, |
| 75 HandlerType type) { |
| 76 // The pc (return address) is already on TOS. |
| 77 // This code pushes state, code, frame pointer and parameter pointer. |
| 78 // Check that they are expected next on the stack, int that order. |
| 79 ASSERT_EQ(StackHandlerConstants::kStateOffset, |
| 80 StackHandlerConstants::kPCOffset - kPointerSize); |
| 81 ASSERT_EQ(StackHandlerConstants::kCodeOffset, |
| 82 StackHandlerConstants::kStateOffset - kPointerSize); |
| 83 ASSERT_EQ(StackHandlerConstants::kFPOffset, |
| 84 StackHandlerConstants::kCodeOffset - kPointerSize); |
| 85 ASSERT_EQ(StackHandlerConstants::kPPOffset, |
| 86 StackHandlerConstants::kFPOffset - kPointerSize); |
| 87 |
| 88 if (try_location == IN_JAVASCRIPT) { |
| 89 if (type == TRY_CATCH_HANDLER) { |
| 90 push(Immediate(StackHandler::TRY_CATCH)); |
| 91 } else { |
| 92 push(Immediate(StackHandler::TRY_FINALLY)); |
| 93 } |
| 94 push(Immediate(Smi::FromInt(StackHandler::kCodeNotPresent))); |
| 95 push(rbp); |
| 96 push(rdi); |
| 97 } else { |
| 98 ASSERT(try_location == IN_JS_ENTRY); |
| 99 // The parameter pointer is meaningless here and ebp does not |
| 100 // point to a JS frame. So we save NULL for both pp and ebp. We |
| 101 // expect the code throwing an exception to check ebp before |
| 102 // dereferencing it to restore the context. |
| 103 push(Immediate(StackHandler::ENTRY)); |
| 104 push(Immediate(Smi::FromInt(StackHandler::kCodeNotPresent))); |
| 105 push(Immediate(0)); // NULL frame pointer |
| 106 push(Immediate(0)); // NULL parameter pointer |
| 107 } |
| 108 movq(kScratchRegister, ExternalReference(Top::k_handler_address)); |
| 109 // Cached TOS. |
| 110 movq(rax, Operand(kScratchRegister, 0)); |
| 111 // Link this handler. |
| 112 movq(Operand(kScratchRegister, 0), rsp); |
| 113 } |
| 114 |
| 115 |
73 } } // namespace v8::internal | 116 } } // namespace v8::internal |
OLD | NEW |