OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 if (!IsFastObjectElementsKind(elements_kind)) { | 429 if (!IsFastObjectElementsKind(elements_kind)) { |
430 if (IsFastHoleyElementsKind(elements_kind)) { | 430 if (IsFastHoleyElementsKind(elements_kind)) { |
431 CHECK(!TransitionElements(object, FAST_HOLEY_ELEMENTS, | 431 CHECK(!TransitionElements(object, FAST_HOLEY_ELEMENTS, |
432 isolate)->IsFailure()); | 432 isolate)->IsFailure()); |
433 } else { | 433 } else { |
434 CHECK(!TransitionElements(object, FAST_ELEMENTS, isolate)->IsFailure()); | 434 CHECK(!TransitionElements(object, FAST_ELEMENTS, isolate)->IsFailure()); |
435 } | 435 } |
436 } | 436 } |
437 } | 437 } |
438 | 438 |
439 object->ValidateElements(); | 439 JSObject::ValidateElements(object); |
440 return object; | 440 return object; |
441 } | 441 } |
442 | 442 |
443 | 443 |
444 MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( | 444 MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( |
445 Isolate* isolate, | 445 Isolate* isolate, |
446 Handle<FixedArray> literals, | 446 Handle<FixedArray> literals, |
447 Handle<FixedArray> array) { | 447 Handle<FixedArray> array) { |
448 Handle<FixedArray> elements = CompileTimeValue::GetElements(array); | 448 Handle<FixedArray> elements = CompileTimeValue::GetElements(array); |
449 const bool kHasNoFunctionLiteral = false; | 449 const bool kHasNoFunctionLiteral = false; |
(...skipping 4844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5294 // of a string using [] notation. We need to support this too in | 5294 // of a string using [] notation. We need to support this too in |
5295 // JavaScript. | 5295 // JavaScript. |
5296 // In the case of a String object we just need to redirect the assignment to | 5296 // In the case of a String object we just need to redirect the assignment to |
5297 // the underlying string if the index is in range. Since the underlying | 5297 // the underlying string if the index is in range. Since the underlying |
5298 // string does nothing with the assignment then we can ignore such | 5298 // string does nothing with the assignment then we can ignore such |
5299 // assignments. | 5299 // assignments. |
5300 if (js_object->IsStringObjectWithCharacterAt(index)) { | 5300 if (js_object->IsStringObjectWithCharacterAt(index)) { |
5301 return value; | 5301 return value; |
5302 } | 5302 } |
5303 | 5303 |
5304 js_object->ValidateElements(); | 5304 JSObject::ValidateElements(js_object); |
5305 if (js_object->HasExternalArrayElements() || | 5305 if (js_object->HasExternalArrayElements() || |
5306 js_object->HasFixedTypedArrayElements()) { | 5306 js_object->HasFixedTypedArrayElements()) { |
5307 if (!value->IsNumber() && !value->IsUndefined()) { | 5307 if (!value->IsNumber() && !value->IsUndefined()) { |
5308 bool has_exception; | 5308 bool has_exception; |
5309 Handle<Object> number = | 5309 Handle<Object> number = |
5310 Execution::ToNumber(isolate, value, &has_exception); | 5310 Execution::ToNumber(isolate, value, &has_exception); |
5311 if (has_exception) return Handle<Object>(); // exception | 5311 if (has_exception) return Handle<Object>(); // exception |
5312 value = number; | 5312 value = number; |
5313 } | 5313 } |
5314 } | 5314 } |
5315 Handle<Object> result = JSObject::SetElement(js_object, index, value, attr, | 5315 Handle<Object> result = JSObject::SetElement(js_object, index, value, attr, |
5316 strict_mode, | 5316 strict_mode, |
5317 true, | 5317 true, |
5318 set_mode); | 5318 set_mode); |
5319 js_object->ValidateElements(); | 5319 JSObject::ValidateElements(js_object); |
5320 return result.is_null() ? result : value; | 5320 return result.is_null() ? result : value; |
5321 } | 5321 } |
5322 | 5322 |
5323 if (key->IsName()) { | 5323 if (key->IsName()) { |
5324 Handle<Name> name = Handle<Name>::cast(key); | 5324 Handle<Name> name = Handle<Name>::cast(key); |
5325 if (name->AsArrayIndex(&index)) { | 5325 if (name->AsArrayIndex(&index)) { |
5326 if (js_object->HasExternalArrayElements()) { | 5326 if (js_object->HasExternalArrayElements()) { |
5327 if (!value->IsNumber() && !value->IsUndefined()) { | 5327 if (!value->IsNumber() && !value->IsUndefined()) { |
5328 bool has_exception; | 5328 bool has_exception; |
5329 Handle<Object> number = | 5329 Handle<Object> number = |
(...skipping 5320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10650 return *JSObject::PrepareElementsForSort(object, limit); | 10650 return *JSObject::PrepareElementsForSort(object, limit); |
10651 } | 10651 } |
10652 | 10652 |
10653 | 10653 |
10654 // Move contents of argument 0 (an array) to argument 1 (an array) | 10654 // Move contents of argument 0 (an array) to argument 1 (an array) |
10655 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { | 10655 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { |
10656 HandleScope scope(isolate); | 10656 HandleScope scope(isolate); |
10657 ASSERT(args.length() == 2); | 10657 ASSERT(args.length() == 2); |
10658 CONVERT_ARG_HANDLE_CHECKED(JSArray, from, 0); | 10658 CONVERT_ARG_HANDLE_CHECKED(JSArray, from, 0); |
10659 CONVERT_ARG_HANDLE_CHECKED(JSArray, to, 1); | 10659 CONVERT_ARG_HANDLE_CHECKED(JSArray, to, 1); |
10660 from->ValidateElements(); | 10660 JSObject::ValidateElements(from); |
10661 to->ValidateElements(); | 10661 JSObject::ValidateElements(to); |
10662 | 10662 |
10663 Handle<FixedArrayBase> new_elements(from->elements()); | 10663 Handle<FixedArrayBase> new_elements(from->elements()); |
10664 ElementsKind from_kind = from->GetElementsKind(); | 10664 ElementsKind from_kind = from->GetElementsKind(); |
10665 Handle<Map> new_map = JSObject::GetElementsTransitionMap(to, from_kind); | 10665 Handle<Map> new_map = JSObject::GetElementsTransitionMap(to, from_kind); |
10666 JSObject::SetMapAndElements(to, new_map, new_elements); | 10666 JSObject::SetMapAndElements(to, new_map, new_elements); |
10667 to->set_length(from->length()); | 10667 to->set_length(from->length()); |
10668 | 10668 |
10669 JSObject::ResetElements(from); | 10669 JSObject::ResetElements(from); |
10670 from->set_length(Smi::FromInt(0)); | 10670 from->set_length(Smi::FromInt(0)); |
10671 | 10671 |
10672 to->ValidateElements(); | 10672 JSObject::ValidateElements(to); |
10673 return *to; | 10673 return *to; |
10674 } | 10674 } |
10675 | 10675 |
10676 | 10676 |
10677 // How many elements does this object/array have? | 10677 // How many elements does this object/array have? |
10678 RUNTIME_FUNCTION(MaybeObject*, Runtime_EstimateNumberOfElements) { | 10678 RUNTIME_FUNCTION(MaybeObject*, Runtime_EstimateNumberOfElements) { |
10679 SealHandleScope shs(isolate); | 10679 SealHandleScope shs(isolate); |
10680 ASSERT(args.length() == 1); | 10680 ASSERT(args.length() == 1); |
10681 CONVERT_ARG_CHECKED(JSObject, object, 0); | 10681 CONVERT_ARG_CHECKED(JSObject, object, 0); |
10682 HeapObject* elements = object->elements(); | 10682 HeapObject* elements = object->elements(); |
(...skipping 4575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15258 } | 15258 } |
15259 } | 15259 } |
15260 | 15260 |
15261 | 15261 |
15262 void Runtime::OutOfMemory() { | 15262 void Runtime::OutOfMemory() { |
15263 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15263 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
15264 UNREACHABLE(); | 15264 UNREACHABLE(); |
15265 } | 15265 } |
15266 | 15266 |
15267 } } // namespace v8::internal | 15267 } } // namespace v8::internal |
OLD | NEW |