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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 | 199 |
200 void MacroAssembler::JumpToBuiltin(const ExternalReference& ext) { | 200 void MacroAssembler::JumpToBuiltin(const ExternalReference& ext) { |
201 // Set the entry point and jump to the C entry runtime stub. | 201 // Set the entry point and jump to the C entry runtime stub. |
202 movq(rbx, ext); | 202 movq(rbx, ext); |
203 CEntryStub ces; | 203 CEntryStub ces; |
204 movq(kScratchRegister, ces.GetCode(), RelocInfo::CODE_TARGET); | 204 movq(kScratchRegister, ces.GetCode(), RelocInfo::CODE_TARGET); |
205 jmp(kScratchRegister); | 205 jmp(kScratchRegister); |
206 } | 206 } |
207 | 207 |
208 | 208 |
209 void MacroAssembler::GetBuiltinEntry(Register target, Builtins::JavaScript id) { | |
210 bool resolved; | |
211 Handle<Code> code = ResolveBuiltin(id, &resolved); | |
212 | |
213 const char* name = Builtins::GetName(id); | |
214 int argc = Builtins::GetArgumentsCount(id); | |
215 | |
216 movq(target, code, RelocInfo::EXTERNAL_REFERENCE); // Is external reference? | |
Lasse Reichstein
2009/06/18 10:57:55
No, a Code object is an embedded object or code ta
| |
217 if (!resolved) { | |
218 uint32_t flags = | |
219 Bootstrapper::FixupFlagsArgumentsCount::encode(argc) | | |
220 Bootstrapper::FixupFlagsIsPCRelative::encode(false) | | |
221 Bootstrapper::FixupFlagsUseCodeObject::encode(true); | |
222 Unresolved entry = { pc_offset() - sizeof(intptr_t), flags, name }; | |
223 unresolved_.Add(entry); | |
224 } | |
225 addq(target, Immediate(Code::kHeaderSize - kHeapObjectTag)); | |
226 } | |
227 | |
228 | |
229 Handle<Code> MacroAssembler::ResolveBuiltin(Builtins::JavaScript id, | |
230 bool* resolved) { | |
231 // Move the builtin function into the temporary function slot by | |
232 // reading it from the builtins object. NOTE: We should be able to | |
233 // reduce this to two instructions by putting the function table in | |
234 // the global object instead of the "builtins" object and by using a | |
235 // real register for the function. | |
236 movq(rdx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); | |
237 movq(rdx, FieldOperand(rdx, GlobalObject::kBuiltinsOffset)); | |
238 int builtins_offset = | |
239 JSBuiltinsObject::kJSBuiltinsOffset + (id * kPointerSize); | |
240 movq(rdi, FieldOperand(rdx, builtins_offset)); | |
241 | |
242 | |
243 return Builtins::GetCode(id, resolved); | |
244 } | |
245 | |
246 | |
209 void MacroAssembler::Set(Register dst, int64_t x) { | 247 void MacroAssembler::Set(Register dst, int64_t x) { |
210 if (is_int32(x)) { | 248 if (is_int32(x)) { |
211 movq(dst, Immediate(x)); | 249 movq(dst, Immediate(x)); |
212 } else if (is_uint32(x)) { | 250 } else if (is_uint32(x)) { |
213 movl(dst, Immediate(x)); | 251 movl(dst, Immediate(x)); |
214 } else { | 252 } else { |
215 movq(dst, x, RelocInfo::NONE); | 253 movq(dst, x, RelocInfo::NONE); |
216 } | 254 } |
217 } | 255 } |
218 | 256 |
(...skipping 15 matching lines...) Expand all Loading... | |
234 jmp(kScratchRegister); | 272 jmp(kScratchRegister); |
235 } | 273 } |
236 | 274 |
237 | 275 |
238 void MacroAssembler::Jump(Address destination, RelocInfo::Mode rmode) { | 276 void MacroAssembler::Jump(Address destination, RelocInfo::Mode rmode) { |
239 movq(kScratchRegister, destination, rmode); | 277 movq(kScratchRegister, destination, rmode); |
240 jmp(kScratchRegister); | 278 jmp(kScratchRegister); |
241 } | 279 } |
242 | 280 |
243 | 281 |
282 void MacroAssembler::Jump(Handle<Code> code_object, RelocInfo::Mode rmode) { | |
283 WriteRecordedPositions(); | |
284 ASSERT(RelocInfo::IsCodeTarget(rmode)); | |
285 movq(kScratchRegister, code_object, rmode); | |
286 jmp(kScratchRegister); | |
287 } | |
288 | |
289 | |
244 void MacroAssembler::Call(ExternalReference ext) { | 290 void MacroAssembler::Call(ExternalReference ext) { |
245 movq(kScratchRegister, ext); | 291 movq(kScratchRegister, ext); |
246 call(kScratchRegister); | 292 call(kScratchRegister); |
247 } | 293 } |
248 | 294 |
249 | 295 |
250 void MacroAssembler::Call(Address destination, RelocInfo::Mode rmode) { | 296 void MacroAssembler::Call(Address destination, RelocInfo::Mode rmode) { |
251 movq(kScratchRegister, destination, rmode); | 297 movq(kScratchRegister, destination, rmode); |
252 call(kScratchRegister); | 298 call(kScratchRegister); |
253 } | 299 } |
254 | 300 |
255 | 301 |
302 void MacroAssembler::Call(Handle<Code> code_object, RelocInfo::Mode rmode) { | |
303 WriteRecordedPositions(); | |
304 ASSERT(RelocInfo::IsCodeTarget(rmode)); | |
305 movq(kScratchRegister, code_object, rmode); | |
306 call(kScratchRegister); | |
307 } | |
308 | |
309 | |
256 void MacroAssembler::PushTryHandler(CodeLocation try_location, | 310 void MacroAssembler::PushTryHandler(CodeLocation try_location, |
257 HandlerType type) { | 311 HandlerType type) { |
258 // Adjust this code if not the case. | 312 // Adjust this code if not the case. |
259 ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); | 313 ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); |
260 | 314 |
261 // The pc (return address) is already on TOS. This code pushes state, | 315 // The pc (return address) is already on TOS. This code pushes state, |
262 // frame pointer and current handler. Check that they are expected | 316 // frame pointer and current handler. Check that they are expected |
263 // next on the stack, in that order. | 317 // next on the stack, in that order. |
264 ASSERT_EQ(StackHandlerConstants::kStateOffset, | 318 ASSERT_EQ(StackHandlerConstants::kStateOffset, |
265 StackHandlerConstants::kPCOffset - kPointerSize); | 319 StackHandlerConstants::kPCOffset - kPointerSize); |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
678 push(rcx); | 732 push(rcx); |
679 | 733 |
680 // Clear the top frame. | 734 // Clear the top frame. |
681 ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address); | 735 ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address); |
682 movq(kScratchRegister, c_entry_fp_address); | 736 movq(kScratchRegister, c_entry_fp_address); |
683 movq(Operand(kScratchRegister, 0), Immediate(0)); | 737 movq(Operand(kScratchRegister, 0), Immediate(0)); |
684 } | 738 } |
685 | 739 |
686 | 740 |
687 } } // namespace v8::internal | 741 } } // namespace v8::internal |
OLD | NEW |