OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
10 #include "src/ast-numbering.h" | 10 #include "src/ast-numbering.h" |
(...skipping 10114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10125 HValue* byte_length = Pop(); | 10125 HValue* byte_length = Pop(); |
10126 | 10126 |
10127 { | 10127 { |
10128 NoObservableSideEffectsScope scope(this); | 10128 NoObservableSideEffectsScope scope(this); |
10129 BuildArrayBufferViewInitialization<JSDataView>( | 10129 BuildArrayBufferViewInitialization<JSDataView>( |
10130 obj, buffer, byte_offset, byte_length); | 10130 obj, buffer, byte_offset, byte_length); |
10131 } | 10131 } |
10132 } | 10132 } |
10133 | 10133 |
10134 | 10134 |
10135 static Handle<Map> TypedArrayMap(Isolate* isolate, | |
10136 ExternalArrayType array_type, | |
10137 ElementsKind target_kind) { | |
10138 Handle<Context> native_context = isolate->native_context(); | |
10139 Handle<JSFunction> fun; | |
10140 switch (array_type) { | |
10141 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | |
10142 case kExternal##Type##Array: \ | |
10143 fun = Handle<JSFunction>(native_context->type##_array_fun()); \ | |
10144 break; | |
10145 | |
10146 TYPED_ARRAYS(TYPED_ARRAY_CASE) | |
10147 #undef TYPED_ARRAY_CASE | |
10148 } | |
10149 Handle<Map> map(fun->initial_map()); | |
10150 return Map::AsElementsKind(map, target_kind); | |
10151 } | |
10152 | |
10153 | |
10154 HValue* HOptimizedGraphBuilder::BuildAllocateExternalElements( | 10135 HValue* HOptimizedGraphBuilder::BuildAllocateExternalElements( |
10155 ExternalArrayType array_type, | 10136 ExternalArrayType array_type, |
10156 bool is_zero_byte_offset, | 10137 bool is_zero_byte_offset, |
10157 HValue* buffer, HValue* byte_offset, HValue* length) { | 10138 HValue* buffer, HValue* byte_offset, HValue* length) { |
10158 Handle<Map> external_array_map( | 10139 Handle<Map> external_array_map( |
10159 isolate()->heap()->MapForFixedTypedArray(array_type)); | 10140 isolate()->heap()->MapForFixedTypedArray(array_type)); |
10160 | 10141 |
10161 // The HForceRepresentation is to prevent possible deopt on int-smi | 10142 // The HForceRepresentation is to prevent possible deopt on int-smi |
10162 // conversion after allocation but before the new object fields are set. | 10143 // conversion after allocation but before the new object fields are set. |
10163 length = AddUncasted<HForceRepresentation>(length, Representation::Smi()); | 10144 length = AddUncasted<HForceRepresentation>(length, Representation::Smi()); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10357 Add<HConstant>(static_cast<int32_t>(element_size))); | 10338 Add<HConstant>(static_cast<int32_t>(element_size))); |
10358 | 10339 |
10359 Add<HStoreNamedField>(obj, | 10340 Add<HStoreNamedField>(obj, |
10360 HObjectAccess::ForJSTypedArrayLength(), | 10341 HObjectAccess::ForJSTypedArrayLength(), |
10361 length); | 10342 length); |
10362 | 10343 |
10363 HValue* elements; | 10344 HValue* elements; |
10364 if (buffer != NULL) { | 10345 if (buffer != NULL) { |
10365 elements = BuildAllocateExternalElements( | 10346 elements = BuildAllocateExternalElements( |
10366 array_type, is_zero_byte_offset, buffer, byte_offset, length); | 10347 array_type, is_zero_byte_offset, buffer, byte_offset, length); |
10367 Handle<Map> obj_map = | |
10368 TypedArrayMap(isolate(), array_type, fixed_elements_kind); | |
10369 AddStoreMapConstant(obj, obj_map); | |
10370 } else { | 10348 } else { |
10371 DCHECK(is_zero_byte_offset); | 10349 DCHECK(is_zero_byte_offset); |
10372 elements = BuildAllocateFixedTypedArray(array_type, element_size, | 10350 elements = BuildAllocateFixedTypedArray(array_type, element_size, |
10373 fixed_elements_kind, byte_length, | 10351 fixed_elements_kind, byte_length, |
10374 length, initialize); | 10352 length, initialize); |
10375 } | 10353 } |
10376 Add<HStoreNamedField>( | 10354 Add<HStoreNamedField>( |
10377 obj, HObjectAccess::ForElementsPointer(), elements); | 10355 obj, HObjectAccess::ForElementsPointer(), elements); |
10378 } | 10356 } |
10379 | 10357 |
(...skipping 3328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13708 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13686 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13709 } | 13687 } |
13710 | 13688 |
13711 #ifdef DEBUG | 13689 #ifdef DEBUG |
13712 graph_->Verify(false); // No full verify. | 13690 graph_->Verify(false); // No full verify. |
13713 #endif | 13691 #endif |
13714 } | 13692 } |
13715 | 13693 |
13716 } // namespace internal | 13694 } // namespace internal |
13717 } // namespace v8 | 13695 } // namespace v8 |
OLD | NEW |