OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 ASSERT(IsFastElementsKind(constant_elements_kind)); | 362 ASSERT(IsFastElementsKind(constant_elements_kind)); |
363 Context* native_context = isolate->context()->native_context(); | 363 Context* native_context = isolate->context()->native_context(); |
364 Object* maps_array = native_context->js_array_maps(); | 364 Object* maps_array = native_context->js_array_maps(); |
365 ASSERT(!maps_array->IsUndefined()); | 365 ASSERT(!maps_array->IsUndefined()); |
366 Object* map = FixedArray::cast(maps_array)->get(constant_elements_kind); | 366 Object* map = FixedArray::cast(maps_array)->get(constant_elements_kind); |
367 object->set_map(Map::cast(map)); | 367 object->set_map(Map::cast(map)); |
368 } | 368 } |
369 | 369 |
370 Handle<FixedArrayBase> copied_elements_values; | 370 Handle<FixedArrayBase> copied_elements_values; |
371 if (IsFastDoubleElementsKind(constant_elements_kind)) { | 371 if (IsFastDoubleElementsKind(constant_elements_kind)) { |
372 ASSERT(FLAG_smi_only_arrays); | |
373 copied_elements_values = isolate->factory()->CopyFixedDoubleArray( | 372 copied_elements_values = isolate->factory()->CopyFixedDoubleArray( |
374 Handle<FixedDoubleArray>::cast(constant_elements_values)); | 373 Handle<FixedDoubleArray>::cast(constant_elements_values)); |
375 } else { | 374 } else { |
376 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind)); | 375 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind)); |
377 const bool is_cow = | 376 const bool is_cow = |
378 (constant_elements_values->map() == | 377 (constant_elements_values->map() == |
379 isolate->heap()->fixed_cow_array_map()); | 378 isolate->heap()->fixed_cow_array_map()); |
380 if (is_cow) { | 379 if (is_cow) { |
381 copied_elements_values = constant_elements_values; | 380 copied_elements_values = constant_elements_values; |
382 #if DEBUG | 381 #if DEBUG |
(...skipping 20 matching lines...) Expand all Loading... |
403 CreateLiteralBoilerplate(isolate, literals, fa), | 402 CreateLiteralBoilerplate(isolate, literals, fa), |
404 Object); | 403 Object); |
405 fixed_array_values_copy->set(i, *result); | 404 fixed_array_values_copy->set(i, *result); |
406 } | 405 } |
407 } | 406 } |
408 } | 407 } |
409 } | 408 } |
410 object->set_elements(*copied_elements_values); | 409 object->set_elements(*copied_elements_values); |
411 object->set_length(Smi::FromInt(copied_elements_values->length())); | 410 object->set_length(Smi::FromInt(copied_elements_values->length())); |
412 | 411 |
413 // Ensure that the boilerplate object has FAST_*_ELEMENTS, unless the flag is | |
414 // on or the object is larger than the threshold. | |
415 if (!FLAG_smi_only_arrays && | |
416 constant_elements_values->length() < kSmiLiteralMinimumLength) { | |
417 ElementsKind elements_kind = object->GetElementsKind(); | |
418 if (!IsFastObjectElementsKind(elements_kind)) { | |
419 if (IsFastHoleyElementsKind(elements_kind)) { | |
420 TransitionElements(object, FAST_HOLEY_ELEMENTS, isolate).Check(); | |
421 } else { | |
422 TransitionElements(object, FAST_ELEMENTS, isolate).Check(); | |
423 } | |
424 } | |
425 } | |
426 | |
427 JSObject::ValidateElements(object); | 412 JSObject::ValidateElements(object); |
428 return object; | 413 return object; |
429 } | 414 } |
430 | 415 |
431 | 416 |
432 MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( | 417 MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( |
433 Isolate* isolate, | 418 Isolate* isolate, |
434 Handle<FixedArray> literals, | 419 Handle<FixedArray> literals, |
435 Handle<FixedArray> array) { | 420 Handle<FixedArray> array) { |
436 Handle<FixedArray> elements = CompileTimeValue::GetElements(array); | 421 Handle<FixedArray> elements = CompileTimeValue::GetElements(array); |
(...skipping 4396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4833 int entry = dictionary->FindEntry(key); | 4818 int entry = dictionary->FindEntry(key); |
4834 if ((entry != NameDictionary::kNotFound) && | 4819 if ((entry != NameDictionary::kNotFound) && |
4835 (dictionary->DetailsAt(entry).type() == NORMAL)) { | 4820 (dictionary->DetailsAt(entry).type() == NORMAL)) { |
4836 Object* value = dictionary->ValueAt(entry); | 4821 Object* value = dictionary->ValueAt(entry); |
4837 if (!receiver->IsGlobalObject()) return value; | 4822 if (!receiver->IsGlobalObject()) return value; |
4838 value = PropertyCell::cast(value)->value(); | 4823 value = PropertyCell::cast(value)->value(); |
4839 if (!value->IsTheHole()) return value; | 4824 if (!value->IsTheHole()) return value; |
4840 // If value is the hole do the general lookup. | 4825 // If value is the hole do the general lookup. |
4841 } | 4826 } |
4842 } | 4827 } |
4843 } else if (FLAG_smi_only_arrays && key_obj->IsSmi()) { | 4828 } else if (key_obj->IsSmi()) { |
4844 // JSObject without a name key. If the key is a Smi, check for a | 4829 // JSObject without a name key. If the key is a Smi, check for a |
4845 // definite out-of-bounds access to elements, which is a strong indicator | 4830 // definite out-of-bounds access to elements, which is a strong indicator |
4846 // that subsequent accesses will also call the runtime. Proactively | 4831 // that subsequent accesses will also call the runtime. Proactively |
4847 // transition elements to FAST_*_ELEMENTS to avoid excessive boxing of | 4832 // transition elements to FAST_*_ELEMENTS to avoid excessive boxing of |
4848 // doubles for those future calls in the case that the elements would | 4833 // doubles for those future calls in the case that the elements would |
4849 // become FAST_DOUBLE_ELEMENTS. | 4834 // become FAST_DOUBLE_ELEMENTS. |
4850 Handle<JSObject> js_object = Handle<JSObject>::cast(receiver_obj); | 4835 Handle<JSObject> js_object = Handle<JSObject>::cast(receiver_obj); |
4851 ElementsKind elements_kind = js_object->GetElementsKind(); | 4836 ElementsKind elements_kind = js_object->GetElementsKind(); |
4852 if (IsFastDoubleElementsKind(elements_kind)) { | 4837 if (IsFastDoubleElementsKind(elements_kind)) { |
4853 Handle<Smi> key = Handle<Smi>::cast(key_obj); | 4838 Handle<Smi> key = Handle<Smi>::cast(key_obj); |
(...skipping 10101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14955 } | 14940 } |
14956 return NULL; | 14941 return NULL; |
14957 } | 14942 } |
14958 | 14943 |
14959 | 14944 |
14960 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 14945 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
14961 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 14946 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
14962 } | 14947 } |
14963 | 14948 |
14964 } } // namespace v8::internal | 14949 } } // namespace v8::internal |
OLD | NEW |