OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/runtime/runtime-utils.h" | 8 #include "src/runtime/runtime-utils.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 HandleScope scope(isolate); | 1048 HandleScope scope(isolate); |
1049 DCHECK(args.length() == 1); | 1049 DCHECK(args.length() == 1); |
1050 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); | 1050 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); |
1051 RUNTIME_ASSERT(!array->HasExternalArrayElements() && | 1051 RUNTIME_ASSERT(!array->HasExternalArrayElements() && |
1052 !array->HasFixedTypedArrayElements()); | 1052 !array->HasFixedTypedArrayElements()); |
1053 JSObject::NormalizeElements(array); | 1053 JSObject::NormalizeElements(array); |
1054 return *array; | 1054 return *array; |
1055 } | 1055 } |
1056 | 1056 |
1057 | 1057 |
1058 // GrowArrayElements returns a sentinel Smi if the object was normalized. | |
1059 RUNTIME_FUNCTION(Runtime_GrowArrayElements) { | |
1060 HandleScope scope(isolate); | |
1061 DCHECK(args.length() == 3); | |
1062 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | |
1063 CONVERT_SMI_ARG_CHECKED(key, 1); | |
1064 | |
1065 if (key < 0) { | |
1066 return object->elements(); | |
1067 } | |
1068 | |
1069 uint32_t capacity = static_cast<uint32_t>(object->elements()->length()); | |
1070 uint32_t index = static_cast<uint32_t>(key); | |
1071 | |
1072 if (index >= capacity) { | |
1073 if (object->WouldConvertToSlowElements(index)) { | |
1074 JSObject::NormalizeElements(object); | |
1075 return Smi::FromInt(0); | |
1076 } | |
1077 | |
1078 uint32_t new_capacity = JSObject::NewElementsCapacity(index + 1); | |
1079 ElementsKind kind = object->GetElementsKind(); | |
1080 if (IsFastDoubleElementsKind(kind)) { | |
1081 JSObject::SetFastDoubleElementsCapacity(object, new_capacity); | |
1082 } else { | |
1083 JSObject::SetFastElementsCapacitySmiMode set_capacity_mode = | |
1084 object->HasFastSmiElements() ? JSObject::kAllowSmiElements | |
1085 : JSObject::kDontAllowSmiElements; | |
1086 JSObject::SetFastElementsCapacity(object, new_capacity, | |
1087 set_capacity_mode); | |
1088 } | |
1089 } | |
1090 | |
1091 // On success, return the fixed array elements. | |
1092 return object->elements(); | |
1093 } | |
1094 | |
1095 | |
1096 RUNTIME_FUNCTION(Runtime_HasComplexElements) { | 1058 RUNTIME_FUNCTION(Runtime_HasComplexElements) { |
1097 HandleScope scope(isolate); | 1059 HandleScope scope(isolate); |
1098 DCHECK(args.length() == 1); | 1060 DCHECK(args.length() == 1); |
1099 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); | 1061 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); |
1100 for (PrototypeIterator iter(isolate, array, | 1062 for (PrototypeIterator iter(isolate, array, |
1101 PrototypeIterator::START_AT_RECEIVER); | 1063 PrototypeIterator::START_AT_RECEIVER); |
1102 !iter.IsAtEnd(); iter.Advance()) { | 1064 !iter.IsAtEnd(); iter.Advance()) { |
1103 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { | 1065 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { |
1104 return isolate->heap()->true_value(); | 1066 return isolate->heap()->true_value(); |
1105 } | 1067 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 } | 1187 } |
1226 | 1188 |
1227 | 1189 |
1228 RUNTIME_FUNCTION(RuntimeReference_FastOneByteArrayJoin) { | 1190 RUNTIME_FUNCTION(RuntimeReference_FastOneByteArrayJoin) { |
1229 SealHandleScope shs(isolate); | 1191 SealHandleScope shs(isolate); |
1230 DCHECK(args.length() == 2); | 1192 DCHECK(args.length() == 2); |
1231 return isolate->heap()->undefined_value(); | 1193 return isolate->heap()->undefined_value(); |
1232 } | 1194 } |
1233 } | 1195 } |
1234 } // namespace v8::internal | 1196 } // namespace v8::internal |
OLD | NEW |