| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 Label* then_label) { | 72 Label* then_label) { |
| 73 Label ok; | 73 Label ok; |
| 74 testq(result, result); | 74 testq(result, result); |
| 75 j(not_zero, &ok); | 75 j(not_zero, &ok); |
| 76 testq(op, op); | 76 testq(op, op); |
| 77 j(sign, then_label); | 77 j(sign, then_label); |
| 78 bind(&ok); | 78 bind(&ok); |
| 79 } | 79 } |
| 80 | 80 |
| 81 | 81 |
| 82 void MacroAssembler::ConstructAndTestJSFunction() { | |
| 83 const int initial_buffer_size = 4 * KB; | |
| 84 char* buffer = new char[initial_buffer_size]; | |
| 85 MacroAssembler masm(buffer, initial_buffer_size); | |
| 86 | |
| 87 const uint64_t secret = V8_INT64_C(0xdeadbeefcafebabe); | |
| 88 Handle<String> constant = | |
| 89 Factory::NewStringFromAscii(Vector<const char>("451", 3), TENURED); | |
| 90 #define __ ACCESS_MASM((&masm)) | |
| 91 // Construct a simple JSfunction here, using Assembler and MacroAssembler | |
| 92 // commands. | |
| 93 __ movq(rax, constant, RelocInfo::EMBEDDED_OBJECT); | |
| 94 __ push(rax); | |
| 95 __ CallRuntime(Runtime::kStringParseFloat, 1); | |
| 96 __ movq(kScratchRegister, secret, RelocInfo::NONE); | |
| 97 __ addq(rax, kScratchRegister); | |
| 98 __ ret(0); | |
| 99 #undef __ | |
| 100 CodeDesc desc; | |
| 101 masm.GetCode(&desc); | |
| 102 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION); | |
| 103 Object* code = Heap::CreateCode(desc, NULL, flags, Handle<Object>::null()); | |
| 104 if (!code->IsFailure()) { | |
| 105 Handle<Code> code_handle(Code::cast(code)); | |
| 106 Handle<String> name = | |
| 107 Factory::NewStringFromAscii(Vector<const char>("foo", 3), NOT_TENURED); | |
| 108 Handle<JSFunction> function = | |
| 109 Factory::NewFunction(name, | |
| 110 JS_FUNCTION_TYPE, | |
| 111 JSObject::kHeaderSize, | |
| 112 code_handle, | |
| 113 true); | |
| 114 bool pending_exceptions; | |
| 115 Handle<Object> result = | |
| 116 Execution::Call(function, | |
| 117 Handle<Object>::cast(function), | |
| 118 0, | |
| 119 NULL, | |
| 120 &pending_exceptions); | |
| 121 CHECK(result->IsSmi()); | |
| 122 CHECK(secret + (451 << kSmiTagSize) == reinterpret_cast<uint64_t>(*result)); | |
| 123 } | |
| 124 } | |
| 125 | |
| 126 | |
| 127 void MacroAssembler::Abort(const char* msg) { | 82 void MacroAssembler::Abort(const char* msg) { |
| 128 // We want to pass the msg string like a smi to avoid GC | 83 // We want to pass the msg string like a smi to avoid GC |
| 129 // problems, however msg is not guaranteed to be aligned | 84 // problems, however msg is not guaranteed to be aligned |
| 130 // properly. Instead, we pass an aligned pointer that is | 85 // properly. Instead, we pass an aligned pointer that is |
| 131 // a proper v8 smi, but also pass the alignment difference | 86 // a proper v8 smi, but also pass the alignment difference |
| 132 // from the real pointer as a smi. | 87 // from the real pointer as a smi. |
| 133 intptr_t p1 = reinterpret_cast<intptr_t>(msg); | 88 intptr_t p1 = reinterpret_cast<intptr_t>(msg); |
| 134 intptr_t p0 = (p1 & ~kSmiTagMask) + kSmiTag; | 89 intptr_t p0 = (p1 & ~kSmiTagMask) + kSmiTag; |
| 135 // Note: p0 might not be a valid Smi *value*, but it has a valid Smi tag. | 90 // Note: p0 might not be a valid Smi *value*, but it has a valid Smi tag. |
| 136 ASSERT(reinterpret_cast<Object*>(p0)->IsSmi()); | 91 ASSERT(reinterpret_cast<Object*>(p0)->IsSmi()); |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 push(rcx); | 795 push(rcx); |
| 841 | 796 |
| 842 // Clear the top frame. | 797 // Clear the top frame. |
| 843 ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address); | 798 ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address); |
| 844 movq(kScratchRegister, c_entry_fp_address); | 799 movq(kScratchRegister, c_entry_fp_address); |
| 845 movq(Operand(kScratchRegister, 0), Immediate(0)); | 800 movq(Operand(kScratchRegister, 0), Immediate(0)); |
| 846 } | 801 } |
| 847 | 802 |
| 848 | 803 |
| 849 } } // namespace v8::internal | 804 } } // namespace v8::internal |
| OLD | NEW |