diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index ac544edbb1..bf8b7b977d 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -3080,7 +3080,11 @@ void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { if (access.IsExternalMemory()) { Register result = ToRegister(instr->result()); MemOperand operand = MemOperand(object, offset); - __ Load(result, operand, access.representation()); + if (access.representation().IsByte()) { + __ ldrb(result, operand); + } else { + __ ldr(result, operand); + } return; } @@ -3096,7 +3100,11 @@ void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { object = result; } MemOperand operand = FieldMemOperand(object, offset); - __ Load(result, operand, access.representation()); + if (access.representation().IsByte()) { + __ ldrb(result, operand); + } else { + __ ldr(result, operand); + } } @@ -4199,7 +4207,11 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { if (access.IsExternalMemory()) { Register value = ToRegister(instr->value()); MemOperand operand = MemOperand(object, offset); - __ Store(value, operand, representation); + if (representation.IsByte()) { + __ strb(value, operand); + } else { + __ str(value, operand); + } return; } @@ -4245,7 +4257,11 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; if (access.IsInobject()) { MemOperand operand = FieldMemOperand(object, offset); - __ Store(value, operand, representation); + if (representation.IsByte()) { + __ strb(value, operand); + } else { + __ str(value, operand); + } if (instr->hydrogen()->NeedsWriteBarrier()) { // Update the write barrier for the object for in-object properties. __ RecordWriteField(object, @@ -4260,7 +4276,11 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { } else { __ ldr(scratch, FieldMemOperand(object, JSObject::kPropertiesOffset)); MemOperand operand = FieldMemOperand(scratch, offset); - __ Store(value, operand, representation); + if (representation.IsByte()) { + __ strb(value, operand); + } else { + __ str(value, operand); + } if (instr->hydrogen()->NeedsWriteBarrier()) { // Update the write barrier for the properties array. // object is used as a scratch register. diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc index 82066a6c67..7a5bef8552 100644 --- a/src/arm/macro-assembler-arm.cc +++ b/src/arm/macro-assembler-arm.cc @@ -384,38 +384,6 @@ void MacroAssembler::Usat(Register dst, int satpos, const Operand& src, } -void MacroAssembler::Load(Register dst, - const MemOperand& src, - Representation r) { - ASSERT(!r.IsDouble()); - if (r.IsInteger8()) { - ldrsb(dst, src); - } else if (r.IsUInteger8()) { - ldrb(dst, src); - } else if (r.IsInteger16()) { - ldrsh(dst, src); - } else if (r.IsUInteger16()) { - ldrh(dst, src); - } else { - ldr(dst, src); - } -} - - -void MacroAssembler::Store(Register src, - const MemOperand& dst, - Representation r) { - ASSERT(!r.IsDouble()); - if (r.IsInteger8() || r.IsUInteger8()) { - strb(src, dst); - } else if (r.IsInteger16() || r.IsUInteger16()) { - strh(src, dst); - } else { - str(src, dst); - } -} - - void MacroAssembler::LoadRoot(Register destination, Heap::RootListIndex index, Condition cond) { diff --git a/src/arm/macro-assembler-arm.h b/src/arm/macro-assembler-arm.h index 97b2575fc3..6fb7434590 100644 --- a/src/arm/macro-assembler-arm.h +++ b/src/arm/macro-assembler-arm.h @@ -161,9 +161,6 @@ class MacroAssembler: public Assembler { void Move(Register dst, Register src, Condition cond = al); void Move(DwVfpRegister dst, DwVfpRegister src); - void Load(Register dst, const MemOperand& src, Representation r); - void Store(Register src, const MemOperand& dst, Representation r); - // Load an object from the root table. void LoadRoot(Register destination, Heap::RootListIndex index, diff --git a/src/globals.h b/src/globals.h index 1db48a11d8..3456030b7e 100644 --- a/src/globals.h +++ b/src/globals.h @@ -226,14 +226,6 @@ const int MB = KB * KB; const int GB = KB * KB * KB; const int kMaxInt = 0x7FFFFFFF; const int kMinInt = -kMaxInt - 1; -const int kMaxInt8 = (1 << 7) - 1; -const int kMinInt8 = -(1 << 7); -const int kMaxUInt8 = (1 << 8) - 1; -const int kMinUInt8 = 0; -const int kMaxInt16 = (1 << 15) - 1; -const int kMinInt16 = -(1 << 15); -const int kMaxUInt16 = (1 << 16) - 1; -const int kMinUInt16 = 0; const uint32_t kMaxUInt32 = 0xFFFFFFFFu; diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index 79962db8ad..02abf0bbd0 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -2856,17 +2856,8 @@ Range* HShl::InferRange(Zone* zone) { Range* HLoadNamedField::InferRange(Zone* zone) { - if (access().representation().IsInteger8()) { - return new(zone) Range(kMinInt8, kMaxInt8); - } - if (access().representation().IsUInteger8()) { - return new(zone) Range(kMinUInt8, kMaxUInt8); - } - if (access().representation().IsInteger16()) { - return new(zone) Range(kMinInt16, kMaxInt16); - } - if (access().representation().IsUInteger16()) { - return new(zone) Range(kMinUInt16, kMaxUInt16); + if (access().representation().IsByte()) { + return new(zone) Range(0, 255); } if (access().IsStringLength()) { return new(zone) Range(0, String::kMaxLength); @@ -2877,15 +2868,16 @@ Range* HLoadNamedField::InferRange(Zone* zone) { Range* HLoadKeyed::InferRange(Zone* zone) { switch (elements_kind()) { - case EXTERNAL_BYTE_ELEMENTS: - return new(zone) Range(kMinInt8, kMaxInt8); - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: case EXTERNAL_PIXEL_ELEMENTS: - return new(zone) Range(kMinUInt8, kMaxUInt8); + return new(zone) Range(0, 255); + case EXTERNAL_BYTE_ELEMENTS: + return new(zone) Range(-128, 127); + case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: + return new(zone) Range(0, 255); case EXTERNAL_SHORT_ELEMENTS: - return new(zone) Range(kMinInt16, kMaxInt16); + return new(zone) Range(-32768, 32767); case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: - return new(zone) Range(kMinUInt16, kMaxUInt16); + return new(zone) Range(0, 65535); default: return HValue::InferRange(zone); } diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index b9c0ca9fce..02af875ac1 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -5860,7 +5860,7 @@ class HObjectAccess V8_FINAL { static HObjectAccess ForMapInstanceSize() { return HObjectAccess(kInobject, Map::kInstanceSizeOffset, - Representation::UInteger8()); + Representation::Byte()); } static HObjectAccess ForPropertyCellValue() { @@ -5938,8 +5938,8 @@ class HObjectAccess V8_FINAL { } class PortionField : public BitField {}; - class RepresentationField : public BitField {}; - class OffsetField : public BitField {}; + class RepresentationField : public BitField {}; + class OffsetField : public BitField {}; uint32_t value_; // encodes portion, representation, and offset Handle name_; @@ -5992,10 +5992,7 @@ class HLoadNamedField V8_FINAL : public HTemplateInstruction<1> { SetOperandAt(0, object); Representation representation = access.representation(); - if (representation.IsInteger8() || - representation.IsUInteger8() || - representation.IsInteger16() || - representation.IsUInteger16()) { + if (representation.IsByte()) { set_representation(Representation::Integer32()); } else if (representation.IsSmi()) { set_type(HType::Smi()); @@ -6305,10 +6302,7 @@ class HStoreNamedField V8_FINAL : public HTemplateInstruction<3> { // object must be external in case of external memory access return Representation::External(); } else if (index == 1) { - if (field_representation().IsInteger8() || - field_representation().IsUInteger8() || - field_representation().IsInteger16() || - field_representation().IsUInteger16() || + if (field_representation().IsByte() || field_representation().IsInteger32()) { return Representation::Integer32(); } else if (field_representation().IsDouble() || diff --git a/src/hydrogen-load-elimination.cc b/src/hydrogen-load-elimination.cc index f37de90ff3..3337188f9a 100644 --- a/src/hydrogen-load-elimination.cc +++ b/src/hydrogen-load-elimination.cc @@ -272,7 +272,9 @@ class HLoadEliminationTable : public ZoneObject { KillFieldInternal(object, field, NULL); // Kill the next field in case of overlap. - int size = access.representation().size(); + int size = kPointerSize; + if (access.representation().IsByte()) size = 1; + else if (access.representation().IsInteger32()) size = 4; int next_field = (offset + size - 1) / kPointerSize; if (next_field != field) KillFieldInternal(object, next_field, NULL); } diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index ab95972677..1a8b996e85 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -3273,7 +3273,12 @@ void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { ? MemOperand::StaticVariable(ToExternalReference( LConstantOperand::cast(instr->object()))) : MemOperand(ToRegister(instr->object()), offset); - __ Load(result, operand, access.representation()); + if (access.representation().IsByte()) { + ASSERT(instr->hydrogen()->representation().IsInteger32()); + __ movzx_b(result, operand); + } else { + __ mov(result, operand); + } return; } @@ -3295,7 +3300,12 @@ void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset)); object = result; } - __ Load(result, FieldOperand(object, offset), access.representation()); + if (access.representation().IsByte()) { + ASSERT(instr->hydrogen()->representation().IsInteger32()); + __ movzx_b(result, FieldOperand(object, offset)); + } else { + __ mov(result, FieldOperand(object, offset)); + } } @@ -4468,11 +4478,16 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { ToExternalReference(LConstantOperand::cast(instr->object()))) : MemOperand(ToRegister(instr->object()), offset); if (instr->value()->IsConstantOperand()) { + ASSERT(!representation.IsByte()); LConstantOperand* operand_value = LConstantOperand::cast(instr->value()); __ mov(operand, Immediate(ToInteger32(operand_value))); } else { Register value = ToRegister(instr->value()); - __ Store(value, operand, representation); + if (representation.IsByte()) { + __ mov_b(operand, value); + } else { + __ mov(operand, value); + } } return; } @@ -4550,7 +4565,11 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { LConstantOperand* operand_value = LConstantOperand::cast(instr->value()); if (operand_value->IsRegister()) { Register value = ToRegister(operand_value); - __ Store(value, operand, representation); + if (representation.IsByte()) { + __ mov_b(operand, value); + } else { + __ mov(operand, value); + } } else { Handle handle_value = ToHandle(operand_value); ASSERT(!instr->hydrogen()->NeedsWriteBarrier()); @@ -4558,7 +4577,11 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { } } else { Register value = ToRegister(instr->value()); - __ Store(value, operand, representation); + if (representation.IsByte()) { + __ mov_b(operand, value); + } else { + __ mov(operand, value); + } } if (instr->hydrogen()->NeedsWriteBarrier()) { diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index cc2b59ac6b..a7503b3740 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -2432,8 +2432,7 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { !(FLAG_track_double_fields && instr->field_representation().IsDouble()); LOperand* val; - if (instr->field_representation().IsInteger8() || - instr->field_representation().IsUInteger8()) { + if (instr->field_representation().IsByte()) { // mov_b requires a byte register (i.e. any of eax, ebx, ecx, edx). // Just force the value to be in eax and we're safe here. val = UseFixed(instr->value(), eax); diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc index c673727bb3..235e38c00e 100644 --- a/src/ia32/macro-assembler-ia32.cc +++ b/src/ia32/macro-assembler-ia32.cc @@ -56,34 +56,6 @@ MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size) } -void MacroAssembler::Load(Register dst, const Operand& src, Representation r) { - ASSERT(!r.IsDouble()); - if (r.IsInteger8()) { - movsx_b(dst, src); - } else if (r.IsUInteger8()) { - movzx_b(dst, src); - } else if (r.IsInteger16()) { - movsx_w(dst, src); - } else if (r.IsUInteger16()) { - movzx_w(dst, src); - } else { - mov(dst, src); - } -} - - -void MacroAssembler::Store(Register src, const Operand& dst, Representation r) { - ASSERT(!r.IsDouble()); - if (r.IsInteger8() || r.IsUInteger8()) { - mov_b(dst, src); - } else if (r.IsInteger16() || r.IsUInteger16()) { - mov_w(dst, src); - } else { - mov(dst, src); - } -} - - void MacroAssembler::LoadRoot(Register destination, Heap::RootListIndex index) { if (isolate()->heap()->RootCanBeTreatedAsConstant(index)) { Handle value(&isolate()->heap()->roots_array_start()[index]); diff --git a/src/ia32/macro-assembler-ia32.h b/src/ia32/macro-assembler-ia32.h index 29bb78d1b8..5f1e428d61 100644 --- a/src/ia32/macro-assembler-ia32.h +++ b/src/ia32/macro-assembler-ia32.h @@ -61,9 +61,6 @@ class MacroAssembler: public Assembler { // macro assembler. MacroAssembler(Isolate* isolate, void* buffer, int size); - void Load(Register dst, const Operand& src, Representation r); - void Store(Register src, const Operand& dst, Representation r); - // Operations on roots in the root-array. void LoadRoot(Register destination, Heap::RootListIndex index); void StoreRoot(Register source, Register scratch, Heap::RootListIndex index); diff --git a/src/property-details.h b/src/property-details.h index 92e4f81c01..659fbd1da6 100644 --- a/src/property-details.h +++ b/src/property-details.h @@ -82,10 +82,7 @@ class Representation { public: enum Kind { kNone, - kInteger8, - kUInteger8, - kInteger16, - kUInteger16, + kByte, kSmi, kInteger32, kDouble, @@ -99,12 +96,7 @@ class Representation { static Representation None() { return Representation(kNone); } static Representation Tagged() { return Representation(kTagged); } - static Representation Integer8() { return Representation(kInteger8); } - static Representation UInteger8() { return Representation(kUInteger8); } - static Representation Integer16() { return Representation(kInteger16); } - static Representation UInteger16() { - return Representation(kUInteger16); - } + static Representation Byte() { return Representation(kByte); } static Representation Smi() { return Representation(kSmi); } static Representation Integer32() { return Representation(kInteger32); } static Representation Double() { return Representation(kDouble); } @@ -134,8 +126,6 @@ class Representation { ASSERT(kind_ != kExternal); ASSERT(other.kind_ != kExternal); if (IsHeapObject()) return other.IsDouble() || other.IsNone(); - if (kind_ == kUInteger8 && other.kind_ == kInteger8) return false; - if (kind_ == kUInteger16 && other.kind_ == kInteger16) return false; return kind_ > other.kind_; } @@ -149,26 +139,9 @@ class Representation { return Representation::Tagged(); } - int size() const { - ASSERT(!IsNone()); - if (IsInteger8() || IsUInteger8()) { - return sizeof(uint8_t); - } - if (IsInteger16() || IsUInteger16()) { - return sizeof(uint16_t); - } - if (IsInteger32()) { - return sizeof(uint32_t); - } - return kPointerSize; - } - Kind kind() const { return static_cast(kind_); } bool IsNone() const { return kind_ == kNone; } - bool IsInteger8() const { return kind_ == kInteger8; } - bool IsUInteger8() const { return kind_ == kUInteger8; } - bool IsInteger16() const { return kind_ == kInteger16; } - bool IsUInteger16() const { return kind_ == kUInteger16; } + bool IsByte() const { return kind_ == kByte; } bool IsTagged() const { return kind_ == kTagged; } bool IsSmi() const { return kind_ == kSmi; } bool IsSmiOrTagged() const { return IsSmi() || IsTagged(); } @@ -178,9 +151,7 @@ class Representation { bool IsHeapObject() const { return kind_ == kHeapObject; } bool IsExternal() const { return kind_ == kExternal; } bool IsSpecialization() const { - return IsInteger8() || IsUInteger8() || - IsInteger16() || IsUInteger16() || - IsSmi() || IsInteger32() || IsDouble(); + return IsByte() || IsSmi() || IsInteger32() || IsDouble(); } const char* Mnemonic() const; @@ -285,8 +256,8 @@ class PropertyDetails BASE_EMBEDDED { // Bit fields for fast objects. class DescriptorPointer: public BitField {}; - class RepresentationField: public BitField {}; - class FieldIndexField: public BitField {}; + class RepresentationField: public BitField {}; + class FieldIndexField: public BitField {}; static const int kInitialIndex = 1; diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index 9e8568c2de..d91f0cff4b 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -940,14 +940,8 @@ void MacroAssembler::Cvtlsi2sd(XMMRegister dst, const Operand& src) { void MacroAssembler::Load(Register dst, const Operand& src, Representation r) { ASSERT(!r.IsDouble()); - if (r.IsInteger8()) { - movsxbq(dst, src); - } else if (r.IsUInteger8()) { + if (r.IsByte()) { movzxbl(dst, src); - } else if (r.IsInteger16()) { - movsxwq(dst, src); - } else if (r.IsUInteger16()) { - movzxwl(dst, src); } else if (r.IsInteger32()) { movl(dst, src); } else { @@ -958,10 +952,8 @@ void MacroAssembler::Load(Register dst, const Operand& src, Representation r) { void MacroAssembler::Store(const Operand& dst, Register src, Representation r) { ASSERT(!r.IsDouble()); - if (r.IsInteger8() || r.IsUInteger8()) { + if (r.IsByte()) { movb(dst, src); - } else if (r.IsInteger16() || r.IsUInteger16()) { - movw(dst, src); } else if (r.IsInteger32()) { movl(dst, src); } else { diff --git a/test/cctest/cctest.gyp b/test/cctest/cctest.gyp index 2017d61a2f..1c7dad78cb 100644 --- a/test/cctest/cctest.gyp +++ b/test/cctest/cctest.gyp @@ -94,7 +94,6 @@ 'test-random-number-generator.cc', 'test-regexp.cc', 'test-reloc-info.cc', - 'test-representation.cc', 'test-semaphore.cc', 'test-serialize.cc', 'test-socket.cc', @@ -122,7 +121,6 @@ 'test-code-stubs-ia32.cc', 'test-cpu-ia32.cc', 'test-disasm-ia32.cc', - 'test-macro-assembler-ia32.cc', 'test-log-stack-tracer.cc' ], }], diff --git a/test/cctest/test-macro-assembler-arm.cc b/test/cctest/test-macro-assembler-arm.cc index 3583945e56..77f7abbd44 100644 --- a/test/cctest/test-macro-assembler-arm.cc +++ b/test/cctest/test-macro-assembler-arm.cc @@ -132,100 +132,5 @@ TEST(CopyBytes) { } -typedef int (*F0)(); - - -TEST(LoadAndStoreWithRepresentation) { - v8::internal::V8::Initialize(NULL); - - // Allocate an executable page of memory. - size_t actual_size; - byte* buffer = static_cast(OS::Allocate(Assembler::kMinimalBufferSize, - &actual_size, - true)); - CHECK(buffer); - Isolate* isolate = CcTest::i_isolate(); - HandleScope handles(isolate); - MacroAssembler assembler(isolate, buffer, static_cast(actual_size)); - MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. - masm->set_allow_stub_calls(false); - __ sub(sp, sp, Operand(1 * kPointerSize)); - Label exit; - - // Test 1. - __ mov(r0, Operand(1)); // Test number. - __ mov(r1, Operand(0)); - __ str(r1, MemOperand(sp, 0 * kPointerSize)); - __ mov(r2, Operand(-1)); - __ Store(r2, MemOperand(sp, 0 * kPointerSize), Representation::UInteger8()); - __ ldr(r3, MemOperand(sp, 0 * kPointerSize)); - __ mov(r2, Operand(255)); - __ cmp(r3, r2); - __ b(ne, &exit); - __ mov(r2, Operand(255)); - __ Load(r3, MemOperand(sp, 0 * kPointerSize), Representation::UInteger8()); - __ cmp(r3, r2); - __ b(ne, &exit); - - // Test 2. - __ mov(r0, Operand(2)); // Test number. - __ mov(r1, Operand(0)); - __ str(r1, MemOperand(sp, 0 * kPointerSize)); - __ mov(r2, Operand(-1)); - __ Store(r2, MemOperand(sp, 0 * kPointerSize), Representation::Integer8()); - __ ldr(r3, MemOperand(sp, 0 * kPointerSize)); - __ mov(r2, Operand(255)); - __ cmp(r3, r2); - __ b(ne, &exit); - __ mov(r2, Operand(-1)); - __ Load(r3, MemOperand(sp, 0 * kPointerSize), Representation::Integer8()); - __ cmp(r3, r2); - __ b(ne, &exit); - - // Test 3. - __ mov(r0, Operand(3)); // Test number. - __ mov(r1, Operand(0)); - __ str(r1, MemOperand(sp, 0 * kPointerSize)); - __ mov(r2, Operand(-1)); - __ Store(r2, MemOperand(sp, 0 * kPointerSize), Representation::UInteger16()); - __ ldr(r3, MemOperand(sp, 0 * kPointerSize)); - __ mov(r2, Operand(65535)); - __ cmp(r3, r2); - __ b(ne, &exit); - __ mov(r2, Operand(65535)); - __ Load(r3, MemOperand(sp, 0 * kPointerSize), Representation::UInteger16()); - __ cmp(r3, r2); - __ b(ne, &exit); - - // Test 4. - __ mov(r0, Operand(4)); // Test number. - __ mov(r1, Operand(0)); - __ str(r1, MemOperand(sp, 0 * kPointerSize)); - __ mov(r2, Operand(-1)); - __ Store(r2, MemOperand(sp, 0 * kPointerSize), Representation::Integer16()); - __ ldr(r3, MemOperand(sp, 0 * kPointerSize)); - __ mov(r2, Operand(65535)); - __ cmp(r3, r2); - __ b(ne, &exit); - __ mov(r2, Operand(-1)); - __ Load(r3, MemOperand(sp, 0 * kPointerSize), Representation::Integer16()); - __ cmp(r3, r2); - __ b(ne, &exit); - - __ mov(r0, Operand(0)); // Success. - __ bind(&exit); - __ add(sp, sp, Operand(1 * kPointerSize)); - __ bx(lr); - - CodeDesc desc; - masm->GetCode(&desc); - // Call the function from C++. - - F0 f = FUNCTION_CAST(buffer); - intptr_t result = reinterpret_cast( - CALL_GENERATED_CODE(f, 4, 0, 0, 0, 0)); - - CHECK_EQ(0, result); -} #undef __ diff --git a/test/cctest/test-macro-assembler-ia32.cc b/test/cctest/test-macro-assembler-ia32.cc deleted file mode 100644 index 4c817dcee6..0000000000 --- a/test/cctest/test-macro-assembler-ia32.cc +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2013 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include - -#include "v8.h" - -#include "macro-assembler.h" -#include "factory.h" -#include "platform.h" -#include "serialize.h" -#include "cctest.h" - -using namespace v8::internal; - -#if __GNUC__ -#define STDCALL __attribute__((stdcall)) -#else -#define STDCALL __stdcall -#endif - -typedef int STDCALL F0Type(); -typedef F0Type* F0; - -#define __ masm-> - - -TEST(LoadAndStoreWithRepresentation) { - v8::internal::V8::Initialize(NULL); - - // Allocate an executable page of memory. - size_t actual_size; - byte* buffer = static_cast(OS::Allocate(Assembler::kMinimalBufferSize, - &actual_size, - true)); - CHECK(buffer); - Isolate* isolate = CcTest::i_isolate(); - HandleScope handles(isolate); - MacroAssembler assembler(isolate, buffer, static_cast(actual_size)); - MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. - masm->set_allow_stub_calls(false); - __ push(ebx); - __ push(edx); - __ sub(esp, Immediate(1 * kPointerSize)); - Label exit; - - // Test 1. - __ mov(eax, Immediate(1)); // Test number. - __ mov(Operand(esp, 0 * kPointerSize), Immediate(0)); - __ mov(ebx, Immediate(-1)); - __ Store(ebx, Operand(esp, 0 * kPointerSize), Representation::UInteger8()); - __ mov(ebx, Operand(esp, 0 * kPointerSize)); - __ mov(edx, Immediate(255)); - __ cmp(ebx, edx); - __ j(not_equal, &exit); - __ Load(ebx, Operand(esp, 0 * kPointerSize), Representation::UInteger8()); - __ cmp(ebx, edx); - __ j(not_equal, &exit); - - - // Test 2. - __ mov(eax, Immediate(2)); // Test number. - __ mov(Operand(esp, 0 * kPointerSize), Immediate(0)); - __ mov(ebx, Immediate(-1)); - __ Store(ebx, Operand(esp, 0 * kPointerSize), Representation::Integer8()); - __ mov(ebx, Operand(esp, 0 * kPointerSize)); - __ mov(edx, Immediate(255)); - __ cmp(ebx, edx); - __ j(not_equal, &exit); - __ Load(ebx, Operand(esp, 0 * kPointerSize), Representation::Integer8()); - __ mov(edx, Immediate(-1)); - __ cmp(ebx, edx); - __ j(not_equal, &exit); - - // Test 3. - __ mov(eax, Immediate(3)); // Test number. - __ mov(Operand(esp, 0 * kPointerSize), Immediate(0)); - __ mov(ebx, Immediate(-1)); - __ Store(ebx, Operand(esp, 0 * kPointerSize), Representation::Integer16()); - __ mov(ebx, Operand(esp, 0 * kPointerSize)); - __ mov(edx, Immediate(65535)); - __ cmp(ebx, edx); - __ j(not_equal, &exit); - __ Load(edx, Operand(esp, 0 * kPointerSize), Representation::Integer16()); - __ mov(ebx, Immediate(-1)); - __ cmp(ebx, edx); - __ j(not_equal, &exit); - - // Test 4. - __ mov(eax, Immediate(4)); // Test number. - __ mov(Operand(esp, 0 * kPointerSize), Immediate(0)); - __ mov(ebx, Immediate(-1)); - __ Store(ebx, Operand(esp, 0 * kPointerSize), Representation::UInteger16()); - __ mov(ebx, Operand(esp, 0 * kPointerSize)); - __ mov(edx, Immediate(65535)); - __ cmp(ebx, edx); - __ j(not_equal, &exit); - __ Load(edx, Operand(esp, 0 * kPointerSize), Representation::UInteger16()); - __ cmp(ebx, edx); - __ j(not_equal, &exit); - - __ xor_(eax, eax); // Success. - __ bind(&exit); - __ add(esp, Immediate(1 * kPointerSize)); - __ pop(edx); - __ pop(ebx); - __ ret(0); - - CodeDesc desc; - masm->GetCode(&desc); - // Call the function from C++. - int result = FUNCTION_CAST(buffer)(); - CHECK_EQ(0, result); -} - -#undef __ diff --git a/test/cctest/test-macro-assembler-x64.cc b/test/cctest/test-macro-assembler-x64.cc index 3d28fc0a03..8262ab6127 100644 --- a/test/cctest/test-macro-assembler-x64.cc +++ b/test/cctest/test-macro-assembler-x64.cc @@ -2704,12 +2704,12 @@ TEST(LoadAndStoreWithRepresentation) { __ movq(rax, Immediate(1)); // Test number. __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0)); __ movq(rcx, Immediate(-1)); - __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::UInteger8()); + __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::Byte()); __ movq(rcx, Operand(rsp, 0 * kPointerSize)); __ movl(rdx, Immediate(255)); __ cmpq(rcx, rdx); __ j(not_equal, &exit); - __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::UInteger8()); + __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::Byte()); __ cmpq(rcx, rdx); __ j(not_equal, &exit); @@ -2778,47 +2778,6 @@ TEST(LoadAndStoreWithRepresentation) { __ cmpq(rcx, rdx); __ j(not_equal, &exit); - // Test 7. - __ movq(rax, Immediate(7)); // Test number. - __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0)); - __ movq(rcx, Immediate(-1)); - __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::Integer8()); - __ movq(rcx, Operand(rsp, 0 * kPointerSize)); - __ movl(rdx, Immediate(255)); - __ cmpq(rcx, rdx); - __ j(not_equal, &exit); - __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::Integer8()); - __ movq(rcx, Immediate(-1)); - __ cmpq(rcx, rdx); - __ j(not_equal, &exit); - - // Test 8. - __ movq(rax, Immediate(8)); // Test number. - __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0)); - __ movq(rcx, Immediate(-1)); - __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::Integer16()); - __ movq(rcx, Operand(rsp, 0 * kPointerSize)); - __ movl(rdx, Immediate(65535)); - __ cmpq(rcx, rdx); - __ j(not_equal, &exit); - __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::Integer16()); - __ movq(rcx, Immediate(-1)); - __ cmpq(rcx, rdx); - __ j(not_equal, &exit); - - // Test 9. - __ movq(rax, Immediate(9)); // Test number. - __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0)); - __ movq(rcx, Immediate(-1)); - __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::UInteger16()); - __ movq(rcx, Operand(rsp, 0 * kPointerSize)); - __ movl(rdx, Immediate(65535)); - __ cmpq(rcx, rdx); - __ j(not_equal, &exit); - __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::UInteger16()); - __ cmpq(rcx, rdx); - __ j(not_equal, &exit); - __ xor_(rax, rax); // Success. __ bind(&exit); __ addq(rsp, Immediate(1 * kPointerSize)); diff --git a/test/cctest/test-representation.cc b/test/cctest/test-representation.cc deleted file mode 100644 index 15321f3ce7..0000000000 --- a/test/cctest/test-representation.cc +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2013 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "cctest.h" -#include "types.h" -#include "property-details.h" - -using namespace v8::internal; - - -void TestPairPositive(Representation more_general, - Representation less_general) { - CHECK(more_general.is_more_general_than(less_general)); -} - - -void TestPairNegative(Representation more_general, - Representation less_general) { - CHECK(!more_general.is_more_general_than(less_general)); -} - - -TEST(RepresentationMoreGeneralThan) { - TestPairNegative(Representation::None(), Representation::None()); - TestPairPositive(Representation::Integer8(), Representation::None()); - TestPairPositive(Representation::UInteger8(), Representation::None()); - TestPairPositive(Representation::Integer16(), Representation::None()); - TestPairPositive(Representation::UInteger16(), Representation::None()); - TestPairPositive(Representation::Smi(), Representation::None()); - TestPairPositive(Representation::Integer32(), Representation::None()); - TestPairPositive(Representation::HeapObject(), Representation::None()); - TestPairPositive(Representation::Double(), Representation::None()); - TestPairPositive(Representation::Tagged(), Representation::None()); - - TestPairNegative(Representation::None(), Representation::Integer8()); - TestPairNegative(Representation::Integer8(), Representation::Integer8()); - TestPairNegative(Representation::UInteger8(), Representation::Integer8()); - TestPairPositive(Representation::Integer16(), Representation::Integer8()); - TestPairPositive(Representation::UInteger16(), Representation::Integer8()); - TestPairPositive(Representation::Smi(), Representation::Integer8()); - TestPairPositive(Representation::Integer32(), Representation::Integer8()); - TestPairNegative(Representation::HeapObject(), Representation::Integer8()); - TestPairPositive(Representation::Double(), Representation::Integer8()); - TestPairPositive(Representation::Tagged(), Representation::Integer8()); - - TestPairNegative(Representation::None(), Representation::UInteger8()); - TestPairNegative(Representation::Integer8(), Representation::UInteger8()); - TestPairNegative(Representation::UInteger8(), Representation::UInteger8()); - TestPairPositive(Representation::Integer16(), Representation::UInteger8()); - TestPairPositive(Representation::UInteger16(), Representation::UInteger8()); - TestPairPositive(Representation::Smi(), Representation::UInteger8()); - TestPairPositive(Representation::Integer32(), Representation::UInteger8()); - TestPairNegative(Representation::HeapObject(), Representation::UInteger8()); - TestPairPositive(Representation::Double(), Representation::UInteger8()); - TestPairPositive(Representation::Tagged(), Representation::UInteger8()); - - TestPairNegative(Representation::None(), Representation::Integer16()); - TestPairNegative(Representation::Integer8(), Representation::Integer16()); - TestPairNegative(Representation::UInteger8(), Representation::Integer16()); - TestPairNegative(Representation::Integer16(), Representation::Integer16()); - TestPairNegative(Representation::UInteger16(), Representation::Integer16()); - TestPairPositive(Representation::Smi(), Representation::Integer16()); - TestPairPositive(Representation::Integer32(), Representation::Integer16()); - TestPairNegative(Representation::HeapObject(), Representation::Integer16()); - TestPairPositive(Representation::Double(), Representation::Integer16()); - TestPairPositive(Representation::Tagged(), Representation::Integer16()); - - TestPairNegative(Representation::None(), Representation::UInteger16()); - TestPairNegative(Representation::Integer8(), Representation::UInteger16()); - TestPairNegative(Representation::UInteger8(), Representation::UInteger16()); - TestPairNegative(Representation::Integer16(), Representation::UInteger16()); - TestPairNegative(Representation::UInteger16(), Representation::UInteger16()); - TestPairPositive(Representation::Smi(), Representation::UInteger16()); - TestPairPositive(Representation::Integer32(), Representation::UInteger16()); - TestPairNegative(Representation::HeapObject(), Representation::UInteger16()); - TestPairPositive(Representation::Double(), Representation::UInteger16()); - TestPairPositive(Representation::Tagged(), Representation::UInteger16()); - - TestPairNegative(Representation::None(), Representation::Smi()); - TestPairNegative(Representation::Integer8(), Representation::Smi()); - TestPairNegative(Representation::UInteger8(), Representation::Smi()); - TestPairNegative(Representation::Integer16(), Representation::Smi()); - TestPairNegative(Representation::UInteger16(), Representation::Smi()); - TestPairNegative(Representation::Smi(), Representation::Smi()); - TestPairPositive(Representation::Integer32(), Representation::Smi()); - TestPairNegative(Representation::HeapObject(), Representation::Smi()); - TestPairPositive(Representation::Double(), Representation::Smi()); - TestPairPositive(Representation::Tagged(), Representation::Smi()); - - TestPairNegative(Representation::None(), Representation::Integer32()); - TestPairNegative(Representation::Integer8(), Representation::Integer32()); - TestPairNegative(Representation::UInteger8(), Representation::Integer32()); - TestPairNegative(Representation::Integer16(), Representation::Integer32()); - TestPairNegative(Representation::UInteger16(), Representation::Integer32()); - TestPairNegative(Representation::Smi(), Representation::Integer32()); - TestPairNegative(Representation::Integer32(), Representation::Integer32()); - TestPairNegative(Representation::HeapObject(), Representation::Integer32()); - TestPairPositive(Representation::Double(), Representation::Integer32()); - TestPairPositive(Representation::Tagged(), Representation::Integer32()); -}