diff options
Diffstat (limited to 'deps/v8/src/ia32/codegen-ia32.cc')
-rw-r--r-- | deps/v8/src/ia32/codegen-ia32.cc | 146 |
1 files changed, 14 insertions, 132 deletions
diff --git a/deps/v8/src/ia32/codegen-ia32.cc b/deps/v8/src/ia32/codegen-ia32.cc index 66da29ebb0..a66334e3a0 100644 --- a/deps/v8/src/ia32/codegen-ia32.cc +++ b/deps/v8/src/ia32/codegen-ia32.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/ia32/codegen-ia32.h" - #if V8_TARGET_ARCH_IA32 #include "src/codegen.h" @@ -16,14 +14,13 @@ namespace internal { #define __ masm. - UnaryMathFunctionWithIsolate CreateSqrtFunction(Isolate* isolate) { - size_t actual_size; - // Allocate buffer in executable space. + size_t allocated = 0; byte* buffer = - static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); + AllocateSystemPage(isolate->heap()->GetRandomMmapAddr(), &allocated); if (buffer == nullptr) return nullptr; - MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size), + + MacroAssembler masm(isolate, buffer, static_cast<int>(allocated), CodeObjectRequired::kNo); // esp[1 * kPointerSize]: raw double input // esp[0 * kPointerSize]: return address @@ -41,8 +38,9 @@ UnaryMathFunctionWithIsolate CreateSqrtFunction(Isolate* isolate) { masm.GetCode(isolate, &desc); DCHECK(!RelocInfo::RequiresRelocation(isolate, desc)); - Assembler::FlushICache(isolate, buffer, actual_size); - base::OS::ProtectCode(buffer, actual_size); + Assembler::FlushICache(isolate, buffer, allocated); + CHECK(base::OS::SetPermissions(buffer, allocated, + base::OS::MemoryPermission::kReadExecute)); return FUNCTION_CAST<UnaryMathFunctionWithIsolate>(buffer); } @@ -134,12 +132,12 @@ class LabelConverter { MemMoveFunction CreateMemMoveFunction(Isolate* isolate) { - size_t actual_size; - // Allocate buffer in executable space. + size_t allocated = 0; byte* buffer = - static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); + AllocateSystemPage(isolate->heap()->GetRandomMmapAddr(), &allocated); if (buffer == nullptr) return nullptr; - MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size), + + MacroAssembler masm(isolate, buffer, static_cast<int>(allocated), CodeObjectRequired::kNo); LabelConverter conv(buffer); @@ -453,8 +451,9 @@ MemMoveFunction CreateMemMoveFunction(Isolate* isolate) { CodeDesc desc; masm.GetCode(isolate, &desc); DCHECK(!RelocInfo::RequiresRelocation(isolate, desc)); - Assembler::FlushICache(isolate, buffer, actual_size); - base::OS::ProtectCode(buffer, actual_size); + Assembler::FlushICache(isolate, buffer, allocated); + CHECK(base::OS::SetPermissions(buffer, allocated, + base::OS::MemoryPermission::kReadExecute)); // TODO(jkummerow): It would be nice to register this code creation event // with the PROFILE / GDBJIT system. return FUNCTION_CAST<MemMoveFunction>(buffer); @@ -463,123 +462,6 @@ MemMoveFunction CreateMemMoveFunction(Isolate* isolate) { #undef __ -// ------------------------------------------------------------------------- -// Code generators - -#define __ ACCESS_MASM(masm) - -void StringCharLoadGenerator::Generate(MacroAssembler* masm, - Factory* factory, - Register string, - Register index, - Register result, - Label* call_runtime) { - Label indirect_string_loaded; - __ bind(&indirect_string_loaded); - - // Fetch the instance type of the receiver into result register. - __ mov(result, FieldOperand(string, HeapObject::kMapOffset)); - __ movzx_b(result, FieldOperand(result, Map::kInstanceTypeOffset)); - - // We need special handling for indirect strings. - Label check_sequential; - __ test(result, Immediate(kIsIndirectStringMask)); - __ j(zero, &check_sequential, Label::kNear); - - // Dispatch on the indirect string shape: slice or cons. - Label cons_string, thin_string; - __ and_(result, Immediate(kStringRepresentationMask)); - __ cmp(result, Immediate(kConsStringTag)); - __ j(equal, &cons_string, Label::kNear); - __ cmp(result, Immediate(kThinStringTag)); - __ j(equal, &thin_string, Label::kNear); - - // Handle slices. - __ mov(result, FieldOperand(string, SlicedString::kOffsetOffset)); - __ SmiUntag(result); - __ add(index, result); - __ mov(string, FieldOperand(string, SlicedString::kParentOffset)); - __ jmp(&indirect_string_loaded); - - // Handle thin strings. - __ bind(&thin_string); - __ mov(string, FieldOperand(string, ThinString::kActualOffset)); - __ jmp(&indirect_string_loaded); - - // Handle cons strings. - // Check whether the right hand side is the empty string (i.e. if - // this is really a flat string in a cons string). If that is not - // the case we would rather go to the runtime system now to flatten - // the string. - __ bind(&cons_string); - __ cmp(FieldOperand(string, ConsString::kSecondOffset), - Immediate(factory->empty_string())); - __ j(not_equal, call_runtime); - __ mov(string, FieldOperand(string, ConsString::kFirstOffset)); - __ jmp(&indirect_string_loaded); - - // Distinguish sequential and external strings. Only these two string - // representations can reach here (slices and flat cons strings have been - // reduced to the underlying sequential or external string). - Label seq_string; - __ bind(&check_sequential); - STATIC_ASSERT(kSeqStringTag == 0); - __ test(result, Immediate(kStringRepresentationMask)); - __ j(zero, &seq_string, Label::kNear); - - // Handle external strings. - Label one_byte_external, done; - if (FLAG_debug_code) { - // Assert that we do not have a cons or slice (indirect strings) here. - // Sequential strings have already been ruled out. - __ test(result, Immediate(kIsIndirectStringMask)); - __ Assert(zero, kExternalStringExpectedButNotFound); - } - // Rule out short external strings. - STATIC_ASSERT(kShortExternalStringTag != 0); - __ test_b(result, Immediate(kShortExternalStringMask)); - __ j(not_zero, call_runtime); - // Check encoding. - STATIC_ASSERT(kTwoByteStringTag == 0); - __ test_b(result, Immediate(kStringEncodingMask)); - __ mov(result, FieldOperand(string, ExternalString::kResourceDataOffset)); - __ j(not_equal, &one_byte_external, Label::kNear); - // Two-byte string. - __ movzx_w(result, Operand(result, index, times_2, 0)); - __ jmp(&done, Label::kNear); - __ bind(&one_byte_external); - // One-byte string. - __ movzx_b(result, Operand(result, index, times_1, 0)); - __ jmp(&done, Label::kNear); - - // Dispatch on the encoding: one-byte or two-byte. - Label one_byte; - __ bind(&seq_string); - STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0); - STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); - __ test(result, Immediate(kStringEncodingMask)); - __ j(not_zero, &one_byte, Label::kNear); - - // Two-byte string. - // Load the two-byte character code into the result register. - __ movzx_w(result, FieldOperand(string, - index, - times_2, - SeqTwoByteString::kHeaderSize)); - __ jmp(&done, Label::kNear); - - // One-byte string. - // Load the byte into the result register. - __ bind(&one_byte); - __ movzx_b(result, FieldOperand(string, - index, - times_1, - SeqOneByteString::kHeaderSize)); - __ bind(&done); -} - -#undef __ - } // namespace internal } // namespace v8 |