OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
10 #include "vm/heap.h" | 10 #include "vm/heap.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 public: | 76 public: |
77 void Process(const MemoryRegion& region, intptr_t position) { | 77 void Process(const MemoryRegion& region, intptr_t position) { |
78 // Direct calls are relative to the following instruction on x86. | 78 // Direct calls are relative to the following instruction on x86. |
79 int32_t pointer = region.Load<int32_t>(position); | 79 int32_t pointer = region.Load<int32_t>(position); |
80 int32_t delta = region.start() + position + sizeof(int32_t); | 80 int32_t delta = region.start() + position + sizeof(int32_t); |
81 region.Store<int32_t>(position, pointer - delta); | 81 region.Store<int32_t>(position, pointer - delta); |
82 } | 82 } |
83 }; | 83 }; |
84 | 84 |
85 | 85 |
| 86 int32_t Assembler::jit_cookie() { |
| 87 if (jit_cookie_ == 0) { |
| 88 jit_cookie_ = static_cast<int32_t>( |
| 89 Isolate::Current()->random()->NextUInt32()); |
| 90 } |
| 91 return jit_cookie_; |
| 92 } |
| 93 |
| 94 |
86 void Assembler::InitializeMemoryWithBreakpoints(uword data, intptr_t length) { | 95 void Assembler::InitializeMemoryWithBreakpoints(uword data, intptr_t length) { |
87 memset(reinterpret_cast<void*>(data), Instr::kBreakPointInstruction, length); | 96 memset(reinterpret_cast<void*>(data), Instr::kBreakPointInstruction, length); |
88 } | 97 } |
89 | 98 |
90 | 99 |
91 void Assembler::call(Register reg) { | 100 void Assembler::call(Register reg) { |
92 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 101 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
93 EmitUint8(0xFF); | 102 EmitUint8(0xFF); |
94 EmitRegisterOperand(2, reg); | 103 EmitRegisterOperand(2, reg); |
95 } | 104 } |
(...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1942 EmitUint8(0xB8 + dst); | 1951 EmitUint8(0xB8 + dst); |
1943 buffer_.EmitObject(object); | 1952 buffer_.EmitObject(object); |
1944 } | 1953 } |
1945 } | 1954 } |
1946 | 1955 |
1947 | 1956 |
1948 void Assembler::LoadObjectSafely(Register dst, const Object& object) { | 1957 void Assembler::LoadObjectSafely(Register dst, const Object& object) { |
1949 if (Assembler::IsSafe(object)) { | 1958 if (Assembler::IsSafe(object)) { |
1950 LoadObject(dst, object); | 1959 LoadObject(dst, object); |
1951 } else { | 1960 } else { |
1952 movl(dst, | 1961 int32_t cookie = jit_cookie(); |
1953 Immediate(reinterpret_cast<int32_t>(object.raw()) ^ jit_cookie_)); | 1962 movl(dst, Immediate(reinterpret_cast<int32_t>(object.raw()) ^ cookie)); |
1954 xorl(dst, Immediate(jit_cookie_)); | 1963 xorl(dst, Immediate(cookie)); |
1955 } | 1964 } |
1956 } | 1965 } |
1957 | 1966 |
1958 | 1967 |
1959 void Assembler::PushObject(const Object& object) { | 1968 void Assembler::PushObject(const Object& object) { |
1960 if (object.IsSmi() || object.InVMHeap()) { | 1969 if (object.IsSmi() || object.InVMHeap()) { |
1961 pushl(Immediate(reinterpret_cast<int32_t>(object.raw()))); | 1970 pushl(Immediate(reinterpret_cast<int32_t>(object.raw()))); |
1962 } else { | 1971 } else { |
1963 ASSERT(object.IsNotTemporaryScopedHandle()); | 1972 ASSERT(object.IsNotTemporaryScopedHandle()); |
1964 ASSERT(object.IsOld()); | 1973 ASSERT(object.IsOld()); |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2507 | 2516 |
2508 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 2517 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
2509 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 2518 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
2510 return xmm_reg_names[reg]; | 2519 return xmm_reg_names[reg]; |
2511 } | 2520 } |
2512 | 2521 |
2513 | 2522 |
2514 } // namespace dart | 2523 } // namespace dart |
2515 | 2524 |
2516 #endif // defined TARGET_ARCH_IA32 | 2525 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |