Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Fix invalid native context reference in simd128-tag
Browse files Browse the repository at this point in the history
The solution is to inline the native context load.

BUG=XWALK-2255
(cherry picked from commit 5aa07fb)
  • Loading branch information
huningxin committed Aug 18, 2014
1 parent ad45c4e commit 7fa32ec
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 42 deletions.
33 changes: 21 additions & 12 deletions src/ia32/macro-assembler-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1695,27 +1695,36 @@ void MacroAssembler::AllocateHeapNumber(Register result,


#define SIMD128_HEAP_ALLOCATE_FUNCTIONS(V) \
V(Float32x4, float32x4) \
V(Float64x2, float64x2) \
V(Int32x4, int32x4)
V(Float32x4, float32x4, FLOAT32x4) \
V(Float64x2, float64x2, FLOAT64x2) \
V(Int32x4, int32x4, INT32x4)

#define DECLARE_SIMD_HEAP_ALLOCATE_FUNCTION(TYPE, type) \
void MacroAssembler::Allocate##TYPE(Register result, \
#define DECLARE_SIMD_HEAP_ALLOCATE_FUNCTION(Type, type, TYPE) \
void MacroAssembler::Allocate##Type(Register result, \
Register scratch1, \
Register scratch2, \
Label* gc_required) { \
/* Allocate SIMD128 object */ \
Allocate(TYPE::kSize, result, scratch1, no_reg, gc_required, TAG_OBJECT);\
\
mov(FieldOperand(result, JSObject::kMapOffset), \
Immediate(reinterpret_cast<intptr_t>( \
isolate()->native_context()->type##_function()->initial_map())));\
Allocate(Type::kSize, result, scratch1, no_reg, gc_required, TAG_OBJECT);\
/* Load the initial map and assign to new allocated object. */ \
mov(scratch1, Operand(ebp, StandardFrameConstants::kContextOffset)); \
mov(scratch1, \
Operand(scratch1, \
Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); \
mov(scratch1, \
FieldOperand(scratch1, GlobalObject::kNativeContextOffset)); \
mov(scratch1, \
Operand(scratch1, \
Context::SlotOffset(Context::TYPE##_FUNCTION_INDEX))); \
LoadGlobalFunctionInitialMap(scratch1, scratch1); \
mov(FieldOperand(result, JSObject::kMapOffset), scratch1); \
/* Initialize properties and elements. */ \
mov(FieldOperand(result, JSObject::kPropertiesOffset), \
Immediate(isolate()->factory()->empty_fixed_array())); \
mov(FieldOperand(result, JSObject::kElementsOffset), \
Immediate(isolate()->factory()->empty_fixed_array())); \
/* Allocate FixedTypedArray object */ \
Allocate(FixedTypedArrayBase::kDataOffset + k##TYPE##Size, \
Allocate(FixedTypedArrayBase::kDataOffset + k##Type##Size, \
scratch1, scratch2, no_reg, gc_required, TAG_OBJECT); \
\
mov(FieldOperand(scratch1, FixedTypedArrayBase::kMapOffset), \
Expand All @@ -1725,7 +1734,7 @@ void MacroAssembler::Allocate##TYPE(Register result, \
mov(FieldOperand(scratch1, FixedTypedArrayBase::kLengthOffset), \
scratch2); \
/* Assign TifxedTypedArray object to SIMD128 object */ \
mov(FieldOperand(result, TYPE::kValueOffset), scratch1); \
mov(FieldOperand(result, Type::kValueOffset), scratch1); \
}

SIMD128_HEAP_ALLOCATE_FUNCTIONS(DECLARE_SIMD_HEAP_ALLOCATE_FUNCTION)
Expand Down
16 changes: 8 additions & 8 deletions src/ia32/macro-assembler-ia32.h
Original file line number Diff line number Diff line change
Expand Up @@ -645,20 +645,20 @@ class MacroAssembler: public Assembler {
// Returns tagged pointer in result register, or jumps to gc_required if new
// space is full.
void AllocateFloat32x4(Register result,
Register scratch1,
Register scratch2,
Label* gc_required);

void AllocateInt32x4(Register result,
Register scratch1,
Register scratch2,
Label* gc_required);
Register scratch1,
Register scratch2,
Label* gc_required);

void AllocateFloat64x2(Register result,
Register scratch1,
Register scratch2,
Label* gc_required);

void AllocateInt32x4(Register result,
Register scratch1,
Register scratch2,
Label* gc_required);

// Allocate a sequential string. All the header fields of the string object
// are initialized.
void AllocateTwoByteString(Register result,
Expand Down
33 changes: 21 additions & 12 deletions src/x64/macro-assembler-x64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4679,31 +4679,40 @@ void MacroAssembler::AllocateHeapNumber(Register result,


#define SIMD128_HEAP_ALLOCATE_FUNCTIONS(V) \
V(Float32x4, float32x4) \
V(Float64x2, float64x2) \
V(Int32x4, int32x4)
V(Float32x4, float32x4, FLOAT32x4) \
V(Float64x2, float64x2, FLOAT64x2) \
V(Int32x4, int32x4, INT32x4)

#define DECLARE_SIMD_HEAP_ALLOCATE_FUNCTION(TYPE, type) \
void MacroAssembler::Allocate##TYPE(Register result, \
#define DECLARE_SIMD_HEAP_ALLOCATE_FUNCTION(Type, type, TYPE) \
void MacroAssembler::Allocate##Type(Register result, \
Register scratch1, \
Register scratch2, \
Register scratch3, \
Label* gc_required) { \
/* Allocate SIMD128 object. */ \
Allocate(TYPE::kSize, result, scratch1, no_reg, gc_required, TAG_OBJECT);\
Handle<Map> simd128_map( \
isolate()->native_context()->type##_function()->initial_map()); \
MoveHeapObject(kScratchRegister, simd128_map); \
Allocate(Type::kSize, result, scratch1, no_reg, gc_required, TAG_OBJECT);\
/* Load the initial map and assign to new allocated object. */ \
movp(scratch1, Operand(rbp, StandardFrameConstants::kContextOffset)); \
movp(scratch1, \
Operand(scratch1, \
Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); \
movp(scratch1, \
FieldOperand(scratch1, GlobalObject::kNativeContextOffset)); \
movp(scratch1, \
Operand(scratch1, \
Context::SlotOffset(Context::TYPE##_FUNCTION_INDEX))); \
LoadGlobalFunctionInitialMap(scratch1, scratch1); \
movp(FieldOperand(result, JSObject::kMapOffset), \
kScratchRegister); \
scratch1); \
/* Initialize the properties and elements. */ \
MoveHeapObject(kScratchRegister, \
isolate()->factory()->empty_fixed_array()); \
movp(FieldOperand(result, JSObject::kPropertiesOffset), \
kScratchRegister); \
movp(FieldOperand(result, JSObject::kElementsOffset), \
kScratchRegister); \
/* Allocate FixedTypedArray object. */ \
Allocate(FixedTypedArrayBase::kDataOffset + k##TYPE##Size, \
Allocate(FixedTypedArrayBase::kDataOffset + k##Type##Size, \
scratch1, scratch2, no_reg, gc_required, TAG_OBJECT); \
MoveHeapObject(kScratchRegister, \
isolate()->factory()->fixed_##type##_array_map()); \
Expand All @@ -4714,7 +4723,7 @@ void MacroAssembler::Allocate##TYPE(Register result, \
movp(FieldOperand(scratch1, FixedTypedArrayBase::kLengthOffset), \
scratch2); \
/* Assign FixedTypedArray object to SIMD128 object. */ \
movp(FieldOperand(result, TYPE::kValueOffset), scratch1); \
movp(FieldOperand(result, Type::kValueOffset), scratch1); \
}

SIMD128_HEAP_ALLOCATE_FUNCTIONS(DECLARE_SIMD_HEAP_ALLOCATE_FUNCTION)
Expand Down
20 changes: 10 additions & 10 deletions src/x64/macro-assembler-x64.h
Original file line number Diff line number Diff line change
Expand Up @@ -1203,23 +1203,23 @@ class MacroAssembler: public Assembler {
// Returns tagged pointer in result register, or jumps to gc_required if new
// space is full.
void AllocateFloat32x4(Register result,
Register scratch1,
Register scratch2,
Register scratch3,
Label* gc_required);

void AllocateInt32x4(Register result,
Register scratch1,
Register scratch2,
Register scratch3,
Label* gc_required);
Register scratch1,
Register scratch2,
Register scratch3,
Label* gc_required);

void AllocateFloat64x2(Register result,
Register scratch1,
Register scratch2,
Register scratch3,
Label* gc_required);

void AllocateInt32x4(Register result,
Register scratch1,
Register scratch2,
Register scratch3,
Label* gc_required);

// Allocate a sequential string. All the header fields of the string object
// are initialized.
void AllocateTwoByteString(Register result,
Expand Down

0 comments on commit 7fa32ec

Please sign in to comment.