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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 Abort(msg); | 56 Abort(msg); |
57 // will not return here | 57 // will not return here |
58 bind(&L); | 58 bind(&L); |
59 } | 59 } |
60 | 60 |
61 | 61 |
62 void MacroAssembler::ConstructAndTestJSFunction() { | 62 void MacroAssembler::ConstructAndTestJSFunction() { |
63 const int initial_buffer_size = 4 * KB; | 63 const int initial_buffer_size = 4 * KB; |
64 char* buffer = new char[initial_buffer_size]; | 64 char* buffer = new char[initial_buffer_size]; |
65 MacroAssembler masm(buffer, initial_buffer_size); | 65 MacroAssembler masm(buffer, initial_buffer_size); |
| 66 |
| 67 const uint64_t secret = V8_INT64_C(0xdeadbeefcafebabe); |
66 #define __ ACCESS_MASM((&masm)) | 68 #define __ ACCESS_MASM((&masm)) |
67 // Construct a simple JSfunction here, using Assembler and MacroAssembler | 69 // Construct a simple JSfunction here, using Assembler and MacroAssembler |
68 // commands. | 70 // commands. |
69 __ int3(); | 71 __ movq(rax, secret, RelocInfo::NONE); |
| 72 __ ret(0); |
70 #undef __ | 73 #undef __ |
71 CodeDesc desc; | 74 CodeDesc desc; |
72 masm.GetCode(&desc); | 75 masm.GetCode(&desc); |
73 // TODO(X64): Create the function object and call it. | 76 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION); |
| 77 Object* code = Heap::CreateCode(desc, NULL, flags, Handle<Object>::null()); |
| 78 if (!code->IsFailure()) { |
| 79 Handle<Code> code_handle(Code::cast(code)); |
| 80 Handle<String> name = |
| 81 Factory::NewStringFromAscii(Vector<const char>("foo", 3), NOT_TENURED); |
| 82 Handle<JSFunction> function = |
| 83 Factory::NewFunction(name, |
| 84 JS_FUNCTION_TYPE, |
| 85 JSObject::kHeaderSize, |
| 86 code_handle, |
| 87 true); |
| 88 bool pending_exceptions; |
| 89 Handle<Object> result = |
| 90 Execution::Call(function, |
| 91 Handle<Object>::cast(function), |
| 92 0, |
| 93 NULL, |
| 94 &pending_exceptions); |
| 95 CHECK(result->IsSmi()); |
| 96 CHECK(secret == reinterpret_cast<uint64_t>(*result)); |
| 97 } |
74 } | 98 } |
75 | 99 |
76 | 100 |
77 void MacroAssembler::Abort(const char* msg) { | 101 void MacroAssembler::Abort(const char* msg) { |
78 // We want to pass the msg string like a smi to avoid GC | 102 // We want to pass the msg string like a smi to avoid GC |
79 // problems, however msg is not guaranteed to be aligned | 103 // problems, however msg is not guaranteed to be aligned |
80 // properly. Instead, we pass an aligned pointer that is | 104 // properly. Instead, we pass an aligned pointer that is |
81 // a proper v8 smi, but also pass the alignment difference | 105 // a proper v8 smi, but also pass the alignment difference |
82 // from the real pointer as a smi. | 106 // from the real pointer as a smi. |
83 intptr_t p1 = reinterpret_cast<intptr_t>(msg); | 107 intptr_t p1 = reinterpret_cast<intptr_t>(msg); |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 push(rcx); | 641 push(rcx); |
618 | 642 |
619 // Clear the top frame. | 643 // Clear the top frame. |
620 ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address); | 644 ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address); |
621 movq(kScratchRegister, c_entry_fp_address); | 645 movq(kScratchRegister, c_entry_fp_address); |
622 movq(Operand(kScratchRegister, 0), Immediate(0)); | 646 movq(Operand(kScratchRegister, 0), Immediate(0)); |
623 } | 647 } |
624 | 648 |
625 | 649 |
626 } } // namespace v8::internal | 650 } } // namespace v8::internal |
OLD | NEW |