OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
8 | 8 |
9 #include "codegen.h" | 9 #include "codegen.h" |
10 #include "heap.h" | 10 #include "heap.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 public: | 69 public: |
70 explicit LabelConverter(byte* buffer) : buffer_(buffer) {} | 70 explicit LabelConverter(byte* buffer) : buffer_(buffer) {} |
71 int32_t address(Label* l) const { | 71 int32_t address(Label* l) const { |
72 return reinterpret_cast<int32_t>(buffer_) + l->pos(); | 72 return reinterpret_cast<int32_t>(buffer_) + l->pos(); |
73 } | 73 } |
74 private: | 74 private: |
75 byte* buffer_; | 75 byte* buffer_; |
76 }; | 76 }; |
77 | 77 |
78 | 78 |
79 OS::MemMoveFunction CreateMemMoveFunction() { | 79 MemMoveFunction CreateMemMoveFunction() { |
80 size_t actual_size; | 80 size_t actual_size; |
81 // Allocate buffer in executable space. | 81 // Allocate buffer in executable space. |
82 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true)); | 82 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true)); |
83 if (buffer == NULL) return NULL; | 83 if (buffer == NULL) return NULL; |
84 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 84 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); |
85 LabelConverter conv(buffer); | 85 LabelConverter conv(buffer); |
86 | 86 |
87 // Generated code is put into a fixed, unmovable buffer, and not into | 87 // Generated code is put into a fixed, unmovable buffer, and not into |
88 // the V8 heap. We can't, and don't, refer to any relocatable addresses | 88 // the V8 heap. We can't, and don't, refer to any relocatable addresses |
89 // (e.g. the JavaScript nan-object). | 89 // (e.g. the JavaScript nan-object). |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 __ bind(&pop_and_return); | 178 __ bind(&pop_and_return); |
179 MemMoveEmitPopAndReturn(&masm); | 179 MemMoveEmitPopAndReturn(&masm); |
180 | 180 |
181 CodeDesc desc; | 181 CodeDesc desc; |
182 masm.GetCode(&desc); | 182 masm.GetCode(&desc); |
183 ASSERT(!RelocInfo::RequiresRelocation(desc)); | 183 ASSERT(!RelocInfo::RequiresRelocation(desc)); |
184 CPU::FlushICache(buffer, actual_size); | 184 CPU::FlushICache(buffer, actual_size); |
185 OS::ProtectCode(buffer, actual_size); | 185 OS::ProtectCode(buffer, actual_size); |
186 // TODO(jkummerow): It would be nice to register this code creation event | 186 // TODO(jkummerow): It would be nice to register this code creation event |
187 // with the PROFILE / GDBJIT system. | 187 // with the PROFILE / GDBJIT system. |
188 return FUNCTION_CAST<OS::MemMoveFunction>(buffer); | 188 return FUNCTION_CAST<MemMoveFunction>(buffer); |
189 } | 189 } |
190 | 190 |
191 | 191 |
192 #undef __ | 192 #undef __ |
193 | 193 |
194 // ------------------------------------------------------------------------- | 194 // ------------------------------------------------------------------------- |
195 // Code generators | 195 // Code generators |
196 | 196 |
197 #define __ ACCESS_MASM(masm) | 197 #define __ ACCESS_MASM(masm) |
198 | 198 |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 Code* stub = GetCodeAgeStub(isolate, age, parity); | 623 Code* stub = GetCodeAgeStub(isolate, age, parity); |
624 CodePatcher patcher(sequence, young_length); | 624 CodePatcher patcher(sequence, young_length); |
625 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); | 625 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); |
626 } | 626 } |
627 } | 627 } |
628 | 628 |
629 | 629 |
630 } } // namespace v8::internal | 630 } } // namespace v8::internal |
631 | 631 |
632 #endif // V8_TARGET_ARCH_X87 | 632 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |