Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / v8 / src / heap / heap.cc
index 5c8cd45..df4444a 100644 (file)
@@ -2670,6 +2670,54 @@ AllocationResult Heap::AllocateHeapNumber(double value, MutableMode mode,
 }
 
 
+#define SIMD128_HEAP_ALLOCATE_FUNCTIONS(V) \
+  V(Float32x4, float32x4)                  \
+  V(Float64x2, float64x2)                  \
+  V(Int32x4, int32x4)
+
+
+#define DECLARE_SIMD_HEAP_ALLOCATE_FUNCTION(TYPE, type)               \
+AllocationResult Heap::Allocate##TYPE(type##_value_t value,           \
+                                      PretenureFlag pretenure) {      \
+  STATIC_ASSERT(TYPE::kSize <= Page::kMaxRegularHeapObjectSize);      \
+                                                                      \
+  AllocationSpace space =                                             \
+      SelectSpace(TYPE::kSize, OLD_DATA_SPACE, pretenure);            \
+                                                                      \
+  HeapObject* result;                                                 \
+  { AllocationResult allocation =                                     \
+        AllocateRaw(TYPE::kSize, space, OLD_DATA_SPACE);              \
+    if (!allocation.To(&result)) return allocation;                   \
+  }                                                                   \
+                                                                      \
+  result->set_map_no_write_barrier(                                   \
+  isolate()->native_context()->type##_function()->initial_map());     \
+  JSObject::cast(result)->set_properties(empty_fixed_array());        \
+  JSObject::cast(result)->set_elements(empty_fixed_array());          \
+                                                                      \
+  HeapObject* storage;                                                \
+  int storage_size =                                                  \
+      FixedTypedArrayBase::kDataOffset + k##TYPE##Size;               \
+  space = SelectSpace(storage_size, OLD_DATA_SPACE, pretenure);       \
+  { AllocationResult allocation =                                     \
+       AllocateRaw(storage_size, space, OLD_DATA_SPACE);              \
+    if (!allocation.To(&storage)) return allocation;                  \
+  }                                                                   \
+                                                                      \
+  storage->set_map(                                                   \
+      *isolate()->factory()->fixed_##type##_array_map());             \
+  FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(storage); \
+  elements->set_length(static_cast<int>(1));                          \
+  memset(elements->DataPtr(), 0, elements->DataSize());               \
+  Fixed##TYPE##Array::cast(storage)->set(0, value);                   \
+  TYPE::cast(result)->set_value(storage);                             \
+  return result;                                                      \
+}
+
+
+SIMD128_HEAP_ALLOCATE_FUNCTIONS(DECLARE_SIMD_HEAP_ALLOCATE_FUNCTION)
+
+
 AllocationResult Heap::AllocateCell(Object* value) {
   int size = Cell::kSize;
   STATIC_ASSERT(Cell::kSize <= Page::kMaxRegularHeapObjectSize);