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 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 HandleScope scope(isolate); | 842 HandleScope scope(isolate); |
843 DCHECK(args.length() == 2); | 843 DCHECK(args.length() == 2); |
844 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, holder, 0); | 844 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, holder, 0); |
845 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byteLength, 1); | 845 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byteLength, 1); |
846 if (!holder->byte_length()->IsUndefined()) { | 846 if (!holder->byte_length()->IsUndefined()) { |
847 // ArrayBuffer is already initialized; probably a fuzz test. | 847 // ArrayBuffer is already initialized; probably a fuzz test. |
848 return *holder; | 848 return *holder; |
849 } | 849 } |
850 size_t allocated_length = 0; | 850 size_t allocated_length = 0; |
851 if (!TryNumberToSize(isolate, *byteLength, &allocated_length)) { | 851 if (!TryNumberToSize(isolate, *byteLength, &allocated_length)) { |
852 return isolate->Throw( | 852 THROW_NEW_ERROR_RETURN_FAILURE( |
853 *isolate->factory()->NewRangeError("invalid_array_buffer_length", | 853 isolate, NewRangeError("invalid_array_buffer_length", |
854 HandleVector<Object>(NULL, 0))); | 854 HandleVector<Object>(NULL, 0))); |
855 } | 855 } |
856 if (!Runtime::SetupArrayBufferAllocatingData(isolate, | 856 if (!Runtime::SetupArrayBufferAllocatingData(isolate, |
857 holder, allocated_length)) { | 857 holder, allocated_length)) { |
858 return isolate->Throw( | 858 THROW_NEW_ERROR_RETURN_FAILURE( |
859 *isolate->factory()->NewRangeError("invalid_array_buffer_length", | 859 isolate, NewRangeError("invalid_array_buffer_length", |
860 HandleVector<Object>(NULL, 0))); | 860 HandleVector<Object>(NULL, 0))); |
861 } | 861 } |
862 return *holder; | 862 return *holder; |
863 } | 863 } |
864 | 864 |
865 | 865 |
866 RUNTIME_FUNCTION(Runtime_ArrayBufferGetByteLength) { | 866 RUNTIME_FUNCTION(Runtime_ArrayBufferGetByteLength) { |
867 SealHandleScope shs(isolate); | 867 SealHandleScope shs(isolate); |
868 DCHECK(args.length() == 1); | 868 DCHECK(args.length() == 1); |
869 CONVERT_ARG_CHECKED(JSArrayBuffer, holder, 0); | 869 CONVERT_ARG_CHECKED(JSArrayBuffer, holder, 0); |
870 return holder->byte_length(); | 870 return holder->byte_length(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 RUNTIME_ASSERT(byte_offset <= array_buffer_byte_length); | 980 RUNTIME_ASSERT(byte_offset <= array_buffer_byte_length); |
981 RUNTIME_ASSERT(array_buffer_byte_length - byte_offset >= byte_length); | 981 RUNTIME_ASSERT(array_buffer_byte_length - byte_offset >= byte_length); |
982 } else { | 982 } else { |
983 RUNTIME_ASSERT(maybe_buffer->IsNull()); | 983 RUNTIME_ASSERT(maybe_buffer->IsNull()); |
984 } | 984 } |
985 | 985 |
986 RUNTIME_ASSERT(byte_length % element_size == 0); | 986 RUNTIME_ASSERT(byte_length % element_size == 0); |
987 size_t length = byte_length / element_size; | 987 size_t length = byte_length / element_size; |
988 | 988 |
989 if (length > static_cast<unsigned>(Smi::kMaxValue)) { | 989 if (length > static_cast<unsigned>(Smi::kMaxValue)) { |
990 return isolate->Throw( | 990 THROW_NEW_ERROR_RETURN_FAILURE( |
991 *isolate->factory()->NewRangeError("invalid_typed_array_length", | 991 isolate, NewRangeError("invalid_typed_array_length", |
992 HandleVector<Object>(NULL, 0))); | 992 HandleVector<Object>(NULL, 0))); |
993 } | 993 } |
994 | 994 |
995 // All checks are done, now we can modify objects. | 995 // All checks are done, now we can modify objects. |
996 | 996 |
997 DCHECK(holder->GetInternalFieldCount() == | 997 DCHECK(holder->GetInternalFieldCount() == |
998 v8::ArrayBufferView::kInternalFieldCount); | 998 v8::ArrayBufferView::kInternalFieldCount); |
999 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 999 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { |
1000 holder->SetInternalField(i, Smi::FromInt(0)); | 1000 holder->SetInternalField(i, Smi::FromInt(0)); |
1001 } | 1001 } |
1002 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); | 1002 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); | 1062 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); |
1063 if (source->IsJSTypedArray() && | 1063 if (source->IsJSTypedArray() && |
1064 JSTypedArray::cast(*source)->type() == array_type) { | 1064 JSTypedArray::cast(*source)->type() == array_type) { |
1065 length_obj = Handle<Object>(JSTypedArray::cast(*source)->length(), isolate); | 1065 length_obj = Handle<Object>(JSTypedArray::cast(*source)->length(), isolate); |
1066 } | 1066 } |
1067 size_t length = 0; | 1067 size_t length = 0; |
1068 RUNTIME_ASSERT(TryNumberToSize(isolate, *length_obj, &length)); | 1068 RUNTIME_ASSERT(TryNumberToSize(isolate, *length_obj, &length)); |
1069 | 1069 |
1070 if ((length > static_cast<unsigned>(Smi::kMaxValue)) || | 1070 if ((length > static_cast<unsigned>(Smi::kMaxValue)) || |
1071 (length > (kMaxInt / element_size))) { | 1071 (length > (kMaxInt / element_size))) { |
1072 return isolate->Throw(*isolate->factory()-> | 1072 THROW_NEW_ERROR_RETURN_FAILURE( |
1073 NewRangeError("invalid_typed_array_length", | 1073 isolate, NewRangeError("invalid_typed_array_length", |
1074 HandleVector<Object>(NULL, 0))); | 1074 HandleVector<Object>(NULL, 0))); |
1075 } | 1075 } |
1076 size_t byte_length = length * element_size; | 1076 size_t byte_length = length * element_size; |
1077 | 1077 |
1078 DCHECK(holder->GetInternalFieldCount() == | 1078 DCHECK(holder->GetInternalFieldCount() == |
1079 v8::ArrayBufferView::kInternalFieldCount); | 1079 v8::ArrayBufferView::kInternalFieldCount); |
1080 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 1080 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { |
1081 holder->SetInternalField(i, Smi::FromInt(0)); | 1081 holder->SetInternalField(i, Smi::FromInt(0)); |
1082 } | 1082 } |
1083 | 1083 |
1084 // NOTE: not initializing backing store. | 1084 // NOTE: not initializing backing store. |
1085 // We assume that the caller of this function will initialize holder | 1085 // We assume that the caller of this function will initialize holder |
1086 // with the loop | 1086 // with the loop |
1087 // for(i = 0; i < length; i++) { holder[i] = source[i]; } | 1087 // for(i = 0; i < length; i++) { holder[i] = source[i]; } |
1088 // We assume that the caller of this function is always a typed array | 1088 // We assume that the caller of this function is always a typed array |
1089 // constructor. | 1089 // constructor. |
1090 // If source is a typed array, this loop will always run to completion, | 1090 // If source is a typed array, this loop will always run to completion, |
1091 // so we are sure that the backing store will be initialized. | 1091 // so we are sure that the backing store will be initialized. |
1092 // Otherwise, the indexing operation might throw, so the loop will not | 1092 // Otherwise, the indexing operation might throw, so the loop will not |
1093 // run to completion and the typed array might remain partly initialized. | 1093 // run to completion and the typed array might remain partly initialized. |
1094 // However we further assume that the caller of this function is a typed array | 1094 // However we further assume that the caller of this function is a typed array |
1095 // constructor, and the exception will propagate out of the constructor, | 1095 // constructor, and the exception will propagate out of the constructor, |
1096 // therefore uninitialized memory will not be accessible by a user program. | 1096 // therefore uninitialized memory will not be accessible by a user program. |
1097 // | 1097 // |
1098 // TODO(dslomov): revise this once we support subclassing. | 1098 // TODO(dslomov): revise this once we support subclassing. |
1099 | 1099 |
1100 if (!Runtime::SetupArrayBufferAllocatingData( | 1100 if (!Runtime::SetupArrayBufferAllocatingData( |
1101 isolate, buffer, byte_length, false)) { | 1101 isolate, buffer, byte_length, false)) { |
1102 return isolate->Throw(*isolate->factory()-> | 1102 THROW_NEW_ERROR_RETURN_FAILURE( |
1103 NewRangeError("invalid_array_buffer_length", | 1103 isolate, NewRangeError("invalid_array_buffer_length", |
1104 HandleVector<Object>(NULL, 0))); | 1104 HandleVector<Object>(NULL, 0))); |
1105 } | 1105 } |
1106 | 1106 |
1107 holder->set_buffer(*buffer); | 1107 holder->set_buffer(*buffer); |
1108 holder->set_byte_offset(Smi::FromInt(0)); | 1108 holder->set_byte_offset(Smi::FromInt(0)); |
1109 Handle<Object> byte_length_obj( | 1109 Handle<Object> byte_length_obj( |
1110 isolate->factory()->NewNumberFromSize(byte_length)); | 1110 isolate->factory()->NewNumberFromSize(byte_length)); |
1111 holder->set_byte_length(*byte_length_obj); | 1111 holder->set_byte_length(*byte_length_obj); |
1112 holder->set_length(*length_obj); | 1112 holder->set_length(*length_obj); |
1113 holder->set_weak_next(buffer->weak_first_view()); | 1113 holder->set_weak_next(buffer->weak_first_view()); |
1114 buffer->set_weak_first_view(*holder); | 1114 buffer->set_weak_first_view(*holder); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1176 // Set from typed array of the different type, non-overlapping. | 1176 // Set from typed array of the different type, non-overlapping. |
1177 TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, | 1177 TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, |
1178 // Set from non-typed array. | 1178 // Set from non-typed array. |
1179 TYPED_ARRAY_SET_NON_TYPED_ARRAY = 3 | 1179 TYPED_ARRAY_SET_NON_TYPED_ARRAY = 3 |
1180 }; | 1180 }; |
1181 | 1181 |
1182 | 1182 |
1183 RUNTIME_FUNCTION(Runtime_TypedArraySetFastCases) { | 1183 RUNTIME_FUNCTION(Runtime_TypedArraySetFastCases) { |
1184 HandleScope scope(isolate); | 1184 HandleScope scope(isolate); |
1185 DCHECK(args.length() == 3); | 1185 DCHECK(args.length() == 3); |
1186 if (!args[0]->IsJSTypedArray()) | 1186 if (!args[0]->IsJSTypedArray()) { |
1187 return isolate->Throw(*isolate->factory()->NewTypeError( | 1187 THROW_NEW_ERROR_RETURN_FAILURE( |
1188 "not_typed_array", HandleVector<Object>(NULL, 0))); | 1188 isolate, |
| 1189 NewTypeError("not_typed_array", HandleVector<Object>(NULL, 0))); |
| 1190 } |
1189 | 1191 |
1190 if (!args[1]->IsJSTypedArray()) | 1192 if (!args[1]->IsJSTypedArray()) |
1191 return Smi::FromInt(TYPED_ARRAY_SET_NON_TYPED_ARRAY); | 1193 return Smi::FromInt(TYPED_ARRAY_SET_NON_TYPED_ARRAY); |
1192 | 1194 |
1193 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, target_obj, 0); | 1195 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, target_obj, 0); |
1194 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, source_obj, 1); | 1196 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, source_obj, 1); |
1195 CONVERT_NUMBER_ARG_HANDLE_CHECKED(offset_obj, 2); | 1197 CONVERT_NUMBER_ARG_HANDLE_CHECKED(offset_obj, 2); |
1196 | 1198 |
1197 Handle<JSTypedArray> target(JSTypedArray::cast(*target_obj)); | 1199 Handle<JSTypedArray> target(JSTypedArray::cast(*target_obj)); |
1198 Handle<JSTypedArray> source(JSTypedArray::cast(*source_obj)); | 1200 Handle<JSTypedArray> source(JSTypedArray::cast(*source_obj)); |
1199 size_t offset = 0; | 1201 size_t offset = 0; |
1200 RUNTIME_ASSERT(TryNumberToSize(isolate, *offset_obj, &offset)); | 1202 RUNTIME_ASSERT(TryNumberToSize(isolate, *offset_obj, &offset)); |
1201 size_t target_length = NumberToSize(isolate, target->length()); | 1203 size_t target_length = NumberToSize(isolate, target->length()); |
1202 size_t source_length = NumberToSize(isolate, source->length()); | 1204 size_t source_length = NumberToSize(isolate, source->length()); |
1203 size_t target_byte_length = NumberToSize(isolate, target->byte_length()); | 1205 size_t target_byte_length = NumberToSize(isolate, target->byte_length()); |
1204 size_t source_byte_length = NumberToSize(isolate, source->byte_length()); | 1206 size_t source_byte_length = NumberToSize(isolate, source->byte_length()); |
1205 if (offset > target_length || | 1207 if (offset > target_length || offset + source_length > target_length || |
1206 offset + source_length > target_length || | 1208 offset + source_length < offset) { // overflow |
1207 offset + source_length < offset) // overflow | 1209 THROW_NEW_ERROR_RETURN_FAILURE( |
1208 return isolate->Throw(*isolate->factory()->NewRangeError( | 1210 isolate, NewRangeError("typed_array_set_source_too_large", |
1209 "typed_array_set_source_too_large", HandleVector<Object>(NULL, 0))); | 1211 HandleVector<Object>(NULL, 0))); |
| 1212 } |
1210 | 1213 |
1211 size_t target_offset = NumberToSize(isolate, target->byte_offset()); | 1214 size_t target_offset = NumberToSize(isolate, target->byte_offset()); |
1212 size_t source_offset = NumberToSize(isolate, source->byte_offset()); | 1215 size_t source_offset = NumberToSize(isolate, source->byte_offset()); |
1213 uint8_t* target_base = | 1216 uint8_t* target_base = |
1214 static_cast<uint8_t*>( | 1217 static_cast<uint8_t*>( |
1215 target->GetBuffer()->backing_store()) + target_offset; | 1218 target->GetBuffer()->backing_store()) + target_offset; |
1216 uint8_t* source_base = | 1219 uint8_t* source_base = |
1217 static_cast<uint8_t*>( | 1220 static_cast<uint8_t*>( |
1218 source->GetBuffer()->backing_store()) + source_offset; | 1221 source->GetBuffer()->backing_store()) + source_offset; |
1219 | 1222 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 static_cast<uint8_t*>(buffer->backing_store()) + buffer_offset; | 1397 static_cast<uint8_t*>(buffer->backing_store()) + buffer_offset; |
1395 if (NeedToFlipBytes(is_little_endian)) { | 1398 if (NeedToFlipBytes(is_little_endian)) { |
1396 FlipBytes<sizeof(T)>(target, value.bytes); | 1399 FlipBytes<sizeof(T)>(target, value.bytes); |
1397 } else { | 1400 } else { |
1398 CopyBytes<sizeof(T)>(target, value.bytes); | 1401 CopyBytes<sizeof(T)>(target, value.bytes); |
1399 } | 1402 } |
1400 return true; | 1403 return true; |
1401 } | 1404 } |
1402 | 1405 |
1403 | 1406 |
1404 #define DATA_VIEW_GETTER(TypeName, Type, Converter) \ | 1407 #define DATA_VIEW_GETTER(TypeName, Type, Converter) \ |
1405 RUNTIME_FUNCTION(Runtime_DataViewGet##TypeName) { \ | 1408 RUNTIME_FUNCTION(Runtime_DataViewGet##TypeName) { \ |
1406 HandleScope scope(isolate); \ | 1409 HandleScope scope(isolate); \ |
1407 DCHECK(args.length() == 3); \ | 1410 DCHECK(args.length() == 3); \ |
1408 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ | 1411 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ |
1409 CONVERT_NUMBER_ARG_HANDLE_CHECKED(offset, 1); \ | 1412 CONVERT_NUMBER_ARG_HANDLE_CHECKED(offset, 1); \ |
1410 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 2); \ | 1413 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 2); \ |
1411 Type result; \ | 1414 Type result; \ |
1412 if (DataViewGetValue( \ | 1415 if (DataViewGetValue(isolate, holder, offset, is_little_endian, \ |
1413 isolate, holder, offset, is_little_endian, &result)) { \ | 1416 &result)) { \ |
1414 return *isolate->factory()->Converter(result); \ | 1417 return *isolate->factory()->Converter(result); \ |
1415 } else { \ | 1418 } else { \ |
1416 return isolate->Throw(*isolate->factory()->NewRangeError( \ | 1419 THROW_NEW_ERROR_RETURN_FAILURE( \ |
1417 "invalid_data_view_accessor_offset", \ | 1420 isolate, NewRangeError("invalid_data_view_accessor_offset", \ |
1418 HandleVector<Object>(NULL, 0))); \ | 1421 HandleVector<Object>(NULL, 0))); \ |
1419 } \ | 1422 } \ |
1420 } | 1423 } |
1421 | 1424 |
1422 DATA_VIEW_GETTER(Uint8, uint8_t, NewNumberFromUint) | 1425 DATA_VIEW_GETTER(Uint8, uint8_t, NewNumberFromUint) |
1423 DATA_VIEW_GETTER(Int8, int8_t, NewNumberFromInt) | 1426 DATA_VIEW_GETTER(Int8, int8_t, NewNumberFromInt) |
1424 DATA_VIEW_GETTER(Uint16, uint16_t, NewNumberFromUint) | 1427 DATA_VIEW_GETTER(Uint16, uint16_t, NewNumberFromUint) |
1425 DATA_VIEW_GETTER(Int16, int16_t, NewNumberFromInt) | 1428 DATA_VIEW_GETTER(Int16, int16_t, NewNumberFromInt) |
1426 DATA_VIEW_GETTER(Uint32, uint32_t, NewNumberFromUint) | 1429 DATA_VIEW_GETTER(Uint32, uint32_t, NewNumberFromUint) |
1427 DATA_VIEW_GETTER(Int32, int32_t, NewNumberFromInt) | 1430 DATA_VIEW_GETTER(Int32, int32_t, NewNumberFromInt) |
1428 DATA_VIEW_GETTER(Float32, float, NewNumber) | 1431 DATA_VIEW_GETTER(Float32, float, NewNumber) |
1429 DATA_VIEW_GETTER(Float64, double, NewNumber) | 1432 DATA_VIEW_GETTER(Float64, double, NewNumber) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 return static_cast<float>(value); | 1479 return static_cast<float>(value); |
1477 } | 1480 } |
1478 | 1481 |
1479 | 1482 |
1480 template <> | 1483 template <> |
1481 double DataViewConvertValue<double>(double value) { | 1484 double DataViewConvertValue<double>(double value) { |
1482 return value; | 1485 return value; |
1483 } | 1486 } |
1484 | 1487 |
1485 | 1488 |
1486 #define DATA_VIEW_SETTER(TypeName, Type) \ | 1489 #define DATA_VIEW_SETTER(TypeName, Type) \ |
1487 RUNTIME_FUNCTION(Runtime_DataViewSet##TypeName) { \ | 1490 RUNTIME_FUNCTION(Runtime_DataViewSet##TypeName) { \ |
1488 HandleScope scope(isolate); \ | 1491 HandleScope scope(isolate); \ |
1489 DCHECK(args.length() == 4); \ | 1492 DCHECK(args.length() == 4); \ |
1490 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ | 1493 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ |
1491 CONVERT_NUMBER_ARG_HANDLE_CHECKED(offset, 1); \ | 1494 CONVERT_NUMBER_ARG_HANDLE_CHECKED(offset, 1); \ |
1492 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); \ | 1495 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); \ |
1493 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 3); \ | 1496 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 3); \ |
1494 Type v = DataViewConvertValue<Type>(value->Number()); \ | 1497 Type v = DataViewConvertValue<Type>(value->Number()); \ |
1495 if (DataViewSetValue( \ | 1498 if (DataViewSetValue(isolate, holder, offset, is_little_endian, v)) { \ |
1496 isolate, holder, offset, is_little_endian, v)) { \ | 1499 return isolate->heap()->undefined_value(); \ |
1497 return isolate->heap()->undefined_value(); \ | 1500 } else { \ |
1498 } else { \ | 1501 THROW_NEW_ERROR_RETURN_FAILURE( \ |
1499 return isolate->Throw(*isolate->factory()->NewRangeError( \ | 1502 isolate, NewRangeError("invalid_data_view_accessor_offset", \ |
1500 "invalid_data_view_accessor_offset", \ | 1503 HandleVector<Object>(NULL, 0))); \ |
1501 HandleVector<Object>(NULL, 0))); \ | 1504 } \ |
1502 } \ | |
1503 } | 1505 } |
1504 | 1506 |
1505 DATA_VIEW_SETTER(Uint8, uint8_t) | 1507 DATA_VIEW_SETTER(Uint8, uint8_t) |
1506 DATA_VIEW_SETTER(Int8, int8_t) | 1508 DATA_VIEW_SETTER(Int8, int8_t) |
1507 DATA_VIEW_SETTER(Uint16, uint16_t) | 1509 DATA_VIEW_SETTER(Uint16, uint16_t) |
1508 DATA_VIEW_SETTER(Int16, int16_t) | 1510 DATA_VIEW_SETTER(Int16, int16_t) |
1509 DATA_VIEW_SETTER(Uint32, uint32_t) | 1511 DATA_VIEW_SETTER(Uint32, uint32_t) |
1510 DATA_VIEW_SETTER(Int32, int32_t) | 1512 DATA_VIEW_SETTER(Int32, int32_t) |
1511 DATA_VIEW_SETTER(Float32, float) | 1513 DATA_VIEW_SETTER(Float32, float) |
1512 DATA_VIEW_SETTER(Float64, double) | 1514 DATA_VIEW_SETTER(Float64, double) |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2160 Handle<Map> new_map = Map::Copy(old_map); | 2162 Handle<Map> new_map = Map::Copy(old_map); |
2161 new_map->set_is_access_check_needed(true); | 2163 new_map->set_is_access_check_needed(true); |
2162 JSObject::MigrateToMap(object, new_map); | 2164 JSObject::MigrateToMap(object, new_map); |
2163 return isolate->heap()->undefined_value(); | 2165 return isolate->heap()->undefined_value(); |
2164 } | 2166 } |
2165 | 2167 |
2166 | 2168 |
2167 static Object* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) { | 2169 static Object* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) { |
2168 HandleScope scope(isolate); | 2170 HandleScope scope(isolate); |
2169 Handle<Object> args[1] = { name }; | 2171 Handle<Object> args[1] = { name }; |
2170 Handle<Object> error = isolate->factory()->NewTypeError( | 2172 THROW_NEW_ERROR_RETURN_FAILURE( |
2171 "var_redeclaration", HandleVector(args, 1)); | 2173 isolate, NewTypeError("var_redeclaration", HandleVector(args, 1))); |
2172 return isolate->Throw(*error); | |
2173 } | 2174 } |
2174 | 2175 |
2175 | 2176 |
2176 // May throw a RedeclarationError. | 2177 // May throw a RedeclarationError. |
2177 static Object* DeclareGlobals(Isolate* isolate, Handle<GlobalObject> global, | 2178 static Object* DeclareGlobals(Isolate* isolate, Handle<GlobalObject> global, |
2178 Handle<String> name, Handle<Object> value, | 2179 Handle<String> name, Handle<Object> value, |
2179 PropertyAttributes attr, bool is_var, | 2180 PropertyAttributes attr, bool is_var, |
2180 bool is_const, bool is_function) { | 2181 bool is_const, bool is_function) { |
2181 // Do the lookup own properties only, see ES5 erratum. | 2182 // Do the lookup own properties only, see ES5 erratum. |
2182 LookupIterator it(global, name, LookupIterator::HIDDEN_PROPERTY); | 2183 LookupIterator it(global, name, LookupIterator::HIDDEN_PROPERTY); |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3068 | 3069 |
3069 | 3070 |
3070 RUNTIME_FUNCTION(Runtime_ThrowGeneratorStateError) { | 3071 RUNTIME_FUNCTION(Runtime_ThrowGeneratorStateError) { |
3071 HandleScope scope(isolate); | 3072 HandleScope scope(isolate); |
3072 DCHECK(args.length() == 1); | 3073 DCHECK(args.length() == 1); |
3073 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); | 3074 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); |
3074 int continuation = generator->continuation(); | 3075 int continuation = generator->continuation(); |
3075 const char* message = continuation == JSGeneratorObject::kGeneratorClosed ? | 3076 const char* message = continuation == JSGeneratorObject::kGeneratorClosed ? |
3076 "generator_finished" : "generator_running"; | 3077 "generator_finished" : "generator_running"; |
3077 Vector< Handle<Object> > argv = HandleVector<Object>(NULL, 0); | 3078 Vector< Handle<Object> > argv = HandleVector<Object>(NULL, 0); |
3078 Handle<Object> error = isolate->factory()->NewError(message, argv); | 3079 THROW_NEW_ERROR_RETURN_FAILURE(isolate, NewError(message, argv)); |
3079 return isolate->Throw(*error); | |
3080 } | 3080 } |
3081 | 3081 |
3082 | 3082 |
3083 RUNTIME_FUNCTION(Runtime_ObjectFreeze) { | 3083 RUNTIME_FUNCTION(Runtime_ObjectFreeze) { |
3084 HandleScope scope(isolate); | 3084 HandleScope scope(isolate); |
3085 DCHECK(args.length() == 1); | 3085 DCHECK(args.length() == 1); |
3086 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 3086 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
3087 | 3087 |
3088 // %ObjectFreeze is a fast path and these cases are handled elsewhere. | 3088 // %ObjectFreeze is a fast path and these cases are handled elsewhere. |
3089 RUNTIME_ASSERT(!object->HasSloppyArgumentsElements() && | 3089 RUNTIME_ASSERT(!object->HasSloppyArgumentsElements() && |
(...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4806 if (!maybe.has_value) return MaybeHandle<Object>(); | 4806 if (!maybe.has_value) return MaybeHandle<Object>(); |
4807 return isolate->factory()->ToBoolean(maybe.value); | 4807 return isolate->factory()->ToBoolean(maybe.value); |
4808 } | 4808 } |
4809 | 4809 |
4810 | 4810 |
4811 MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate, | 4811 MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate, |
4812 Handle<Object> object, | 4812 Handle<Object> object, |
4813 Handle<Object> key) { | 4813 Handle<Object> key) { |
4814 if (object->IsUndefined() || object->IsNull()) { | 4814 if (object->IsUndefined() || object->IsNull()) { |
4815 Handle<Object> args[2] = { key, object }; | 4815 Handle<Object> args[2] = { key, object }; |
4816 return isolate->Throw<Object>( | 4816 THROW_NEW_ERROR(isolate, NewTypeError("non_object_property_load", |
4817 isolate->factory()->NewTypeError("non_object_property_load", | 4817 HandleVector(args, 2)), |
4818 HandleVector(args, 2))); | 4818 Object); |
4819 } | 4819 } |
4820 | 4820 |
4821 // Check if the given key is an array index. | 4821 // Check if the given key is an array index. |
4822 uint32_t index; | 4822 uint32_t index; |
4823 if (key->ToArrayIndex(&index)) { | 4823 if (key->ToArrayIndex(&index)) { |
4824 return GetElementOrCharAt(isolate, object, index); | 4824 return GetElementOrCharAt(isolate, object, index); |
4825 } | 4825 } |
4826 | 4826 |
4827 // Convert the key to a name - possibly by calling back into JavaScript. | 4827 // Convert the key to a name - possibly by calling back into JavaScript. |
4828 Handle<Name> name; | 4828 Handle<Name> name; |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5081 } | 5081 } |
5082 | 5082 |
5083 | 5083 |
5084 MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, | 5084 MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, |
5085 Handle<Object> object, | 5085 Handle<Object> object, |
5086 Handle<Object> key, | 5086 Handle<Object> key, |
5087 Handle<Object> value, | 5087 Handle<Object> value, |
5088 StrictMode strict_mode) { | 5088 StrictMode strict_mode) { |
5089 if (object->IsUndefined() || object->IsNull()) { | 5089 if (object->IsUndefined() || object->IsNull()) { |
5090 Handle<Object> args[2] = { key, object }; | 5090 Handle<Object> args[2] = { key, object }; |
5091 Handle<Object> error = | 5091 THROW_NEW_ERROR(isolate, NewTypeError("non_object_property_store", |
5092 isolate->factory()->NewTypeError("non_object_property_store", | 5092 HandleVector(args, 2)), |
5093 HandleVector(args, 2)); | 5093 Object); |
5094 return isolate->Throw<Object>(error); | |
5095 } | 5094 } |
5096 | 5095 |
5097 if (object->IsJSProxy()) { | 5096 if (object->IsJSProxy()) { |
5098 Handle<Object> name_object; | 5097 Handle<Object> name_object; |
5099 if (key->IsSymbol()) { | 5098 if (key->IsSymbol()) { |
5100 name_object = key; | 5099 name_object = key; |
5101 } else { | 5100 } else { |
5102 ASSIGN_RETURN_ON_EXCEPTION( | 5101 ASSIGN_RETURN_ON_EXCEPTION( |
5103 isolate, name_object, Execution::ToString(isolate, key), Object); | 5102 isolate, name_object, Execution::ToString(isolate, key), Object); |
5104 } | 5103 } |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5332 duplicate = it.IsFound(); | 5331 duplicate = it.IsFound(); |
5333 } else { | 5332 } else { |
5334 uint32_t index = 0; | 5333 uint32_t index = 0; |
5335 RUNTIME_ASSERT(key->ToArrayIndex(&index)); | 5334 RUNTIME_ASSERT(key->ToArrayIndex(&index)); |
5336 Maybe<bool> maybe = JSReceiver::HasOwnElement(object, index); | 5335 Maybe<bool> maybe = JSReceiver::HasOwnElement(object, index); |
5337 if (!maybe.has_value) return isolate->heap()->exception(); | 5336 if (!maybe.has_value) return isolate->heap()->exception(); |
5338 duplicate = maybe.value; | 5337 duplicate = maybe.value; |
5339 } | 5338 } |
5340 if (duplicate) { | 5339 if (duplicate) { |
5341 Handle<Object> args[1] = { key }; | 5340 Handle<Object> args[1] = { key }; |
5342 Handle<Object> error = isolate->factory()->NewTypeError( | 5341 THROW_NEW_ERROR_RETURN_FAILURE( |
5343 "duplicate_template_property", HandleVector(args, 1)); | 5342 isolate, |
5344 return isolate->Throw(*error); | 5343 NewTypeError("duplicate_template_property", HandleVector(args, 1))); |
5345 } | 5344 } |
5346 #endif | 5345 #endif |
5347 | 5346 |
5348 Handle<Object> result; | 5347 Handle<Object> result; |
5349 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5348 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
5350 isolate, result, | 5349 isolate, result, |
5351 Runtime::DefineObjectProperty(object, key, value, attributes)); | 5350 Runtime::DefineObjectProperty(object, key, value, attributes)); |
5352 return *result; | 5351 return *result; |
5353 } | 5352 } |
5354 | 5353 |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6044 } | 6043 } |
6045 } | 6044 } |
6046 | 6045 |
6047 // Handle special arguments properties. | 6046 // Handle special arguments properties. |
6048 if (String::Equals(isolate->factory()->length_string(), key)) { | 6047 if (String::Equals(isolate->factory()->length_string(), key)) { |
6049 return Smi::FromInt(n); | 6048 return Smi::FromInt(n); |
6050 } | 6049 } |
6051 if (String::Equals(isolate->factory()->callee_string(), key)) { | 6050 if (String::Equals(isolate->factory()->callee_string(), key)) { |
6052 JSFunction* function = frame->function(); | 6051 JSFunction* function = frame->function(); |
6053 if (function->shared()->strict_mode() == STRICT) { | 6052 if (function->shared()->strict_mode() == STRICT) { |
6054 return isolate->Throw(*isolate->factory()->NewTypeError( | 6053 THROW_NEW_ERROR_RETURN_FAILURE( |
6055 "strict_arguments_callee", HandleVector<Object>(NULL, 0))); | 6054 isolate, NewTypeError("strict_arguments_callee", |
| 6055 HandleVector<Object>(NULL, 0))); |
6056 } | 6056 } |
6057 return function; | 6057 return function; |
6058 } | 6058 } |
6059 | 6059 |
6060 // Lookup in the initial Object.prototype object. | 6060 // Lookup in the initial Object.prototype object. |
6061 Handle<Object> result; | 6061 Handle<Object> result; |
6062 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6062 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6063 isolate, result, | 6063 isolate, result, |
6064 Object::GetProperty(isolate->initial_object_prototype(), key)); | 6064 Object::GetProperty(isolate->initial_object_prototype(), key)); |
6065 return *result; | 6065 return *result; |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6441 overflows |= ToUpperOverflows(current); | 6441 overflows |= ToUpperOverflows(current); |
6442 // NOTE: we use 0 as the next character here because, while | 6442 // NOTE: we use 0 as the next character here because, while |
6443 // the next character may affect what a character converts to, | 6443 // the next character may affect what a character converts to, |
6444 // it does not in any case affect the length of what it convert | 6444 // it does not in any case affect the length of what it convert |
6445 // to. | 6445 // to. |
6446 int char_length = mapping->get(current, 0, chars); | 6446 int char_length = mapping->get(current, 0, chars); |
6447 if (char_length == 0) char_length = 1; | 6447 if (char_length == 0) char_length = 1; |
6448 current_length += char_length; | 6448 current_length += char_length; |
6449 if (current_length > String::kMaxLength) { | 6449 if (current_length > String::kMaxLength) { |
6450 AllowHeapAllocation allocate_error_and_return; | 6450 AllowHeapAllocation allocate_error_and_return; |
6451 return isolate->ThrowInvalidStringLength(); | 6451 THROW_NEW_ERROR_RETURN_FAILURE(isolate, |
| 6452 NewInvalidStringLengthError()); |
6452 } | 6453 } |
6453 } | 6454 } |
6454 // Try again with the real length. Return signed if we need | 6455 // Try again with the real length. Return signed if we need |
6455 // to allocate a two-byte string for to uppercase. | 6456 // to allocate a two-byte string for to uppercase. |
6456 return (overflows && !ignore_overflow) ? Smi::FromInt(-current_length) | 6457 return (overflows && !ignore_overflow) ? Smi::FromInt(-current_length) |
6457 : Smi::FromInt(current_length); | 6458 : Smi::FromInt(current_length); |
6458 } else { | 6459 } else { |
6459 for (int j = 0; j < char_length; j++) { | 6460 for (int j = 0; j < char_length; j++) { |
6460 result->Set(i, chars[j]); | 6461 result->Set(i, chars[j]); |
6461 i++; | 6462 i++; |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7156 position += increment; | 7157 position += increment; |
7157 } | 7158 } |
7158 return position; | 7159 return position; |
7159 } | 7160 } |
7160 | 7161 |
7161 | 7162 |
7162 RUNTIME_FUNCTION(Runtime_StringBuilderConcat) { | 7163 RUNTIME_FUNCTION(Runtime_StringBuilderConcat) { |
7163 HandleScope scope(isolate); | 7164 HandleScope scope(isolate); |
7164 DCHECK(args.length() == 3); | 7165 DCHECK(args.length() == 3); |
7165 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 7166 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
7166 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); | 7167 if (!args[1]->IsSmi()) { |
| 7168 THROW_NEW_ERROR_RETURN_FAILURE(isolate, NewInvalidStringLengthError()); |
| 7169 } |
7167 CONVERT_SMI_ARG_CHECKED(array_length, 1); | 7170 CONVERT_SMI_ARG_CHECKED(array_length, 1); |
7168 CONVERT_ARG_HANDLE_CHECKED(String, special, 2); | 7171 CONVERT_ARG_HANDLE_CHECKED(String, special, 2); |
7169 | 7172 |
7170 size_t actual_array_length = 0; | 7173 size_t actual_array_length = 0; |
7171 RUNTIME_ASSERT( | 7174 RUNTIME_ASSERT( |
7172 TryNumberToSize(isolate, array->length(), &actual_array_length)); | 7175 TryNumberToSize(isolate, array->length(), &actual_array_length)); |
7173 RUNTIME_ASSERT(array_length >= 0); | 7176 RUNTIME_ASSERT(array_length >= 0); |
7174 RUNTIME_ASSERT(static_cast<size_t>(array_length) <= actual_array_length); | 7177 RUNTIME_ASSERT(static_cast<size_t>(array_length) <= actual_array_length); |
7175 | 7178 |
7176 // This assumption is used by the slice encoding in one or two smis. | 7179 // This assumption is used by the slice encoding in one or two smis. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7228 array_length); | 7231 array_length); |
7229 return *answer; | 7232 return *answer; |
7230 } | 7233 } |
7231 } | 7234 } |
7232 | 7235 |
7233 | 7236 |
7234 RUNTIME_FUNCTION(Runtime_StringBuilderJoin) { | 7237 RUNTIME_FUNCTION(Runtime_StringBuilderJoin) { |
7235 HandleScope scope(isolate); | 7238 HandleScope scope(isolate); |
7236 DCHECK(args.length() == 3); | 7239 DCHECK(args.length() == 3); |
7237 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 7240 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
7238 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); | 7241 if (!args[1]->IsSmi()) { |
| 7242 THROW_NEW_ERROR_RETURN_FAILURE(isolate, NewInvalidStringLengthError()); |
| 7243 } |
7239 CONVERT_SMI_ARG_CHECKED(array_length, 1); | 7244 CONVERT_SMI_ARG_CHECKED(array_length, 1); |
7240 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); | 7245 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); |
7241 RUNTIME_ASSERT(array->HasFastObjectElements()); | 7246 RUNTIME_ASSERT(array->HasFastObjectElements()); |
7242 RUNTIME_ASSERT(array_length >= 0); | 7247 RUNTIME_ASSERT(array_length >= 0); |
7243 | 7248 |
7244 Handle<FixedArray> fixed_array(FixedArray::cast(array->elements())); | 7249 Handle<FixedArray> fixed_array(FixedArray::cast(array->elements())); |
7245 if (fixed_array->length() < array_length) { | 7250 if (fixed_array->length() < array_length) { |
7246 array_length = fixed_array->length(); | 7251 array_length = fixed_array->length(); |
7247 } | 7252 } |
7248 | 7253 |
7249 if (array_length == 0) { | 7254 if (array_length == 0) { |
7250 return isolate->heap()->empty_string(); | 7255 return isolate->heap()->empty_string(); |
7251 } else if (array_length == 1) { | 7256 } else if (array_length == 1) { |
7252 Object* first = fixed_array->get(0); | 7257 Object* first = fixed_array->get(0); |
7253 RUNTIME_ASSERT(first->IsString()); | 7258 RUNTIME_ASSERT(first->IsString()); |
7254 return first; | 7259 return first; |
7255 } | 7260 } |
7256 | 7261 |
7257 int separator_length = separator->length(); | 7262 int separator_length = separator->length(); |
7258 RUNTIME_ASSERT(separator_length > 0); | 7263 RUNTIME_ASSERT(separator_length > 0); |
7259 int max_nof_separators = | 7264 int max_nof_separators = |
7260 (String::kMaxLength + separator_length - 1) / separator_length; | 7265 (String::kMaxLength + separator_length - 1) / separator_length; |
7261 if (max_nof_separators < (array_length - 1)) { | 7266 if (max_nof_separators < (array_length - 1)) { |
7262 return isolate->ThrowInvalidStringLength(); | 7267 THROW_NEW_ERROR_RETURN_FAILURE(isolate, NewInvalidStringLengthError()); |
7263 } | 7268 } |
7264 int length = (array_length - 1) * separator_length; | 7269 int length = (array_length - 1) * separator_length; |
7265 for (int i = 0; i < array_length; i++) { | 7270 for (int i = 0; i < array_length; i++) { |
7266 Object* element_obj = fixed_array->get(i); | 7271 Object* element_obj = fixed_array->get(i); |
7267 RUNTIME_ASSERT(element_obj->IsString()); | 7272 RUNTIME_ASSERT(element_obj->IsString()); |
7268 String* element = String::cast(element_obj); | 7273 String* element = String::cast(element_obj); |
7269 int increment = element->length(); | 7274 int increment = element->length(); |
7270 if (increment > String::kMaxLength - length) { | 7275 if (increment > String::kMaxLength - length) { |
7271 STATIC_ASSERT(String::kMaxLength < kMaxInt); | 7276 STATIC_ASSERT(String::kMaxLength < kMaxInt); |
7272 length = kMaxInt; // Provoke exception; | 7277 length = kMaxInt; // Provoke exception; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7414 // Nonempty separator and at least 2^31-1 separators necessary | 7419 // Nonempty separator and at least 2^31-1 separators necessary |
7415 // means that the string is too large to create. | 7420 // means that the string is too large to create. |
7416 STATIC_ASSERT(String::kMaxLength < 0x7fffffff); | 7421 STATIC_ASSERT(String::kMaxLength < 0x7fffffff); |
7417 overflow = true; | 7422 overflow = true; |
7418 } | 7423 } |
7419 } | 7424 } |
7420 if (overflow) { | 7425 if (overflow) { |
7421 // Throw an exception if the resulting string is too large. See | 7426 // Throw an exception if the resulting string is too large. See |
7422 // https://code.google.com/p/chromium/issues/detail?id=336820 | 7427 // https://code.google.com/p/chromium/issues/detail?id=336820 |
7423 // for details. | 7428 // for details. |
7424 return isolate->ThrowInvalidStringLength(); | 7429 THROW_NEW_ERROR_RETURN_FAILURE(isolate, NewInvalidStringLengthError()); |
7425 } | 7430 } |
7426 | 7431 |
7427 if (is_ascii) { | 7432 if (is_ascii) { |
7428 Handle<SeqOneByteString> result = isolate->factory()->NewRawOneByteString( | 7433 Handle<SeqOneByteString> result = isolate->factory()->NewRawOneByteString( |
7429 string_length).ToHandleChecked(); | 7434 string_length).ToHandleChecked(); |
7430 JoinSparseArrayWithSeparator<uint8_t>( | 7435 JoinSparseArrayWithSeparator<uint8_t>( |
7431 FixedArray::cast(elements_array->elements()), | 7436 FixedArray::cast(elements_array->elements()), |
7432 elements_length, | 7437 elements_length, |
7433 array_length, | 7438 array_length, |
7434 *separator, | 7439 *separator, |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8319 return *result; | 8324 return *result; |
8320 } | 8325 } |
8321 | 8326 |
8322 | 8327 |
8323 static Object* Runtime_NewObjectHelper(Isolate* isolate, | 8328 static Object* Runtime_NewObjectHelper(Isolate* isolate, |
8324 Handle<Object> constructor, | 8329 Handle<Object> constructor, |
8325 Handle<AllocationSite> site) { | 8330 Handle<AllocationSite> site) { |
8326 // If the constructor isn't a proper function we throw a type error. | 8331 // If the constructor isn't a proper function we throw a type error. |
8327 if (!constructor->IsJSFunction()) { | 8332 if (!constructor->IsJSFunction()) { |
8328 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1); | 8333 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1); |
8329 Handle<Object> type_error = | 8334 THROW_NEW_ERROR_RETURN_FAILURE(isolate, |
8330 isolate->factory()->NewTypeError("not_constructor", arguments); | 8335 NewTypeError("not_constructor", arguments)); |
8331 return isolate->Throw(*type_error); | |
8332 } | 8336 } |
8333 | 8337 |
8334 Handle<JSFunction> function = Handle<JSFunction>::cast(constructor); | 8338 Handle<JSFunction> function = Handle<JSFunction>::cast(constructor); |
8335 | 8339 |
8336 // If function should not have prototype, construction is not allowed. In this | 8340 // If function should not have prototype, construction is not allowed. In this |
8337 // case generated code bailouts here, since function has no initial_map. | 8341 // case generated code bailouts here, since function has no initial_map. |
8338 if (!function->should_have_prototype() && !function->shared()->bound()) { | 8342 if (!function->should_have_prototype() && !function->shared()->bound()) { |
8339 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1); | 8343 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1); |
8340 Handle<Object> type_error = | 8344 THROW_NEW_ERROR_RETURN_FAILURE(isolate, |
8341 isolate->factory()->NewTypeError("not_constructor", arguments); | 8345 NewTypeError("not_constructor", arguments)); |
8342 return isolate->Throw(*type_error); | |
8343 } | 8346 } |
8344 | 8347 |
8345 Debug* debug = isolate->debug(); | 8348 Debug* debug = isolate->debug(); |
8346 // Handle stepping into constructors if step into is active. | 8349 // Handle stepping into constructors if step into is active. |
8347 if (debug->StepInActive()) { | 8350 if (debug->StepInActive()) { |
8348 debug->HandleStepIn(function, Handle<Object>::null(), 0, true); | 8351 debug->HandleStepIn(function, Handle<Object>::null(), 0, true); |
8349 } | 8352 } |
8350 | 8353 |
8351 if (function->has_initial_map()) { | 8354 if (function->has_initial_map()) { |
8352 if (function->initial_map()->instance_type() == JS_FUNCTION_TYPE) { | 8355 if (function->initial_map()->instance_type() == JS_FUNCTION_TYPE) { |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9026 DCHECK(args.length() == 2); | 9029 DCHECK(args.length() == 2); |
9027 Handle<JSReceiver> extension_object; | 9030 Handle<JSReceiver> extension_object; |
9028 if (args[0]->IsJSReceiver()) { | 9031 if (args[0]->IsJSReceiver()) { |
9029 extension_object = args.at<JSReceiver>(0); | 9032 extension_object = args.at<JSReceiver>(0); |
9030 } else { | 9033 } else { |
9031 // Try to convert the object to a proper JavaScript object. | 9034 // Try to convert the object to a proper JavaScript object. |
9032 MaybeHandle<JSReceiver> maybe_object = | 9035 MaybeHandle<JSReceiver> maybe_object = |
9033 Object::ToObject(isolate, args.at<Object>(0)); | 9036 Object::ToObject(isolate, args.at<Object>(0)); |
9034 if (!maybe_object.ToHandle(&extension_object)) { | 9037 if (!maybe_object.ToHandle(&extension_object)) { |
9035 Handle<Object> handle = args.at<Object>(0); | 9038 Handle<Object> handle = args.at<Object>(0); |
9036 Handle<Object> result = | 9039 THROW_NEW_ERROR_RETURN_FAILURE( |
9037 isolate->factory()->NewTypeError("with_expression", | 9040 isolate, NewTypeError("with_expression", HandleVector(&handle, 1))); |
9038 HandleVector(&handle, 1)); | |
9039 return isolate->Throw(*result); | |
9040 } | 9041 } |
9041 } | 9042 } |
9042 | 9043 |
9043 Handle<JSFunction> function; | 9044 Handle<JSFunction> function; |
9044 if (args[1]->IsSmi()) { | 9045 if (args[1]->IsSmi()) { |
9045 // A smi sentinel indicates a context nested inside global code rather | 9046 // A smi sentinel indicates a context nested inside global code rather |
9046 // than some function. There is a canonical empty function that can be | 9047 // than some function. There is a canonical empty function that can be |
9047 // gotten from the native context. | 9048 // gotten from the native context. |
9048 function = handle(isolate->native_context()->closure()); | 9049 function = handle(isolate->native_context()->closure()); |
9049 } else { | 9050 } else { |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9341 DCHECK(holder->IsContext()); | 9342 DCHECK(holder->IsContext()); |
9342 // If the "property" we were looking for is a local variable, the | 9343 // If the "property" we were looking for is a local variable, the |
9343 // receiver is the global object; see ECMA-262, 3rd., 10.1.6 and 10.2.3. | 9344 // receiver is the global object; see ECMA-262, 3rd., 10.1.6 and 10.2.3. |
9344 Handle<Object> receiver = isolate->factory()->undefined_value(); | 9345 Handle<Object> receiver = isolate->factory()->undefined_value(); |
9345 Object* value = Context::cast(*holder)->get(index); | 9346 Object* value = Context::cast(*holder)->get(index); |
9346 // Check for uninitialized bindings. | 9347 // Check for uninitialized bindings. |
9347 switch (binding_flags) { | 9348 switch (binding_flags) { |
9348 case MUTABLE_CHECK_INITIALIZED: | 9349 case MUTABLE_CHECK_INITIALIZED: |
9349 case IMMUTABLE_CHECK_INITIALIZED_HARMONY: | 9350 case IMMUTABLE_CHECK_INITIALIZED_HARMONY: |
9350 if (value->IsTheHole()) { | 9351 if (value->IsTheHole()) { |
9351 Handle<Object> reference_error = | 9352 Handle<Object> error; |
| 9353 MaybeHandle<Object> maybe_error = |
9352 isolate->factory()->NewReferenceError("not_defined", | 9354 isolate->factory()->NewReferenceError("not_defined", |
9353 HandleVector(&name, 1)); | 9355 HandleVector(&name, 1)); |
9354 return MakePair(isolate->Throw(*reference_error), NULL); | 9356 if (maybe_error.ToHandle(&error)) isolate->Throw(*error); |
| 9357 return MakePair(isolate->heap()->exception(), NULL); |
9355 } | 9358 } |
9356 // FALLTHROUGH | 9359 // FALLTHROUGH |
9357 case MUTABLE_IS_INITIALIZED: | 9360 case MUTABLE_IS_INITIALIZED: |
9358 case IMMUTABLE_IS_INITIALIZED: | 9361 case IMMUTABLE_IS_INITIALIZED: |
9359 case IMMUTABLE_IS_INITIALIZED_HARMONY: | 9362 case IMMUTABLE_IS_INITIALIZED_HARMONY: |
9360 DCHECK(!value->IsTheHole()); | 9363 DCHECK(!value->IsTheHole()); |
9361 return MakePair(value, *receiver); | 9364 return MakePair(value, *receiver); |
9362 case IMMUTABLE_CHECK_INITIALIZED: | 9365 case IMMUTABLE_CHECK_INITIALIZED: |
9363 if (value->IsTheHole()) { | 9366 if (value->IsTheHole()) { |
9364 DCHECK((attributes & READ_ONLY) != 0); | 9367 DCHECK((attributes & READ_ONLY) != 0); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9396 Handle<Object> value; | 9399 Handle<Object> value; |
9397 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 9400 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
9398 isolate, value, | 9401 isolate, value, |
9399 Object::GetProperty(object, name), | 9402 Object::GetProperty(object, name), |
9400 MakePair(isolate->heap()->exception(), NULL)); | 9403 MakePair(isolate->heap()->exception(), NULL)); |
9401 return MakePair(*value, *receiver_handle); | 9404 return MakePair(*value, *receiver_handle); |
9402 } | 9405 } |
9403 | 9406 |
9404 if (throw_error) { | 9407 if (throw_error) { |
9405 // The property doesn't exist - throw exception. | 9408 // The property doesn't exist - throw exception. |
9406 Handle<Object> reference_error = | 9409 Handle<Object> error; |
9407 isolate->factory()->NewReferenceError("not_defined", | 9410 MaybeHandle<Object> maybe_error = isolate->factory()->NewReferenceError( |
9408 HandleVector(&name, 1)); | 9411 "not_defined", HandleVector(&name, 1)); |
9409 return MakePair(isolate->Throw(*reference_error), NULL); | 9412 if (maybe_error.ToHandle(&error)) isolate->Throw(*error); |
| 9413 return MakePair(isolate->heap()->exception(), NULL); |
9410 } else { | 9414 } else { |
9411 // The property doesn't exist - return undefined. | 9415 // The property doesn't exist - return undefined. |
9412 return MakePair(isolate->heap()->undefined_value(), | 9416 return MakePair(isolate->heap()->undefined_value(), |
9413 isolate->heap()->undefined_value()); | 9417 isolate->heap()->undefined_value()); |
9414 } | 9418 } |
9415 } | 9419 } |
9416 | 9420 |
9417 | 9421 |
9418 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_LoadLookupSlot) { | 9422 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_LoadLookupSlot) { |
9419 return LoadLookupSlotHelper(args, isolate, true); | 9423 return LoadLookupSlotHelper(args, isolate, true); |
(...skipping 25 matching lines...) Expand all Loading... |
9445 &binding_flags); | 9449 &binding_flags); |
9446 // In case of JSProxy, an exception might have been thrown. | 9450 // In case of JSProxy, an exception might have been thrown. |
9447 if (isolate->has_pending_exception()) return isolate->heap()->exception(); | 9451 if (isolate->has_pending_exception()) return isolate->heap()->exception(); |
9448 | 9452 |
9449 // The property was found in a context slot. | 9453 // The property was found in a context slot. |
9450 if (index >= 0) { | 9454 if (index >= 0) { |
9451 if ((attributes & READ_ONLY) == 0) { | 9455 if ((attributes & READ_ONLY) == 0) { |
9452 Handle<Context>::cast(holder)->set(index, *value); | 9456 Handle<Context>::cast(holder)->set(index, *value); |
9453 } else if (strict_mode == STRICT) { | 9457 } else if (strict_mode == STRICT) { |
9454 // Setting read only property in strict mode. | 9458 // Setting read only property in strict mode. |
9455 Handle<Object> error = | 9459 THROW_NEW_ERROR_RETURN_FAILURE( |
9456 isolate->factory()->NewTypeError("strict_cannot_assign", | 9460 isolate, |
9457 HandleVector(&name, 1)); | 9461 NewTypeError("strict_cannot_assign", HandleVector(&name, 1))); |
9458 return isolate->Throw(*error); | |
9459 } | 9462 } |
9460 return *value; | 9463 return *value; |
9461 } | 9464 } |
9462 | 9465 |
9463 // Slow case: The property is not in a context slot. It is either in a | 9466 // Slow case: The property is not in a context slot. It is either in a |
9464 // context extension object, a property of the subject of a with, or a | 9467 // context extension object, a property of the subject of a with, or a |
9465 // property of the global object. | 9468 // property of the global object. |
9466 Handle<JSReceiver> object; | 9469 Handle<JSReceiver> object; |
9467 if (attributes != ABSENT) { | 9470 if (attributes != ABSENT) { |
9468 // The property exists on the holder. | 9471 // The property exists on the holder. |
9469 object = Handle<JSReceiver>::cast(holder); | 9472 object = Handle<JSReceiver>::cast(holder); |
9470 } else if (strict_mode == STRICT) { | 9473 } else if (strict_mode == STRICT) { |
9471 // If absent in strict mode: throw. | 9474 // If absent in strict mode: throw. |
9472 Handle<Object> error = isolate->factory()->NewReferenceError( | 9475 THROW_NEW_ERROR_RETURN_FAILURE( |
9473 "not_defined", HandleVector(&name, 1)); | 9476 isolate, NewReferenceError("not_defined", HandleVector(&name, 1))); |
9474 return isolate->Throw(*error); | |
9475 } else { | 9477 } else { |
9476 // If absent in sloppy mode: add the property to the global object. | 9478 // If absent in sloppy mode: add the property to the global object. |
9477 object = Handle<JSReceiver>(context->global_object()); | 9479 object = Handle<JSReceiver>(context->global_object()); |
9478 } | 9480 } |
9479 | 9481 |
9480 RETURN_FAILURE_ON_EXCEPTION( | 9482 RETURN_FAILURE_ON_EXCEPTION( |
9481 isolate, Object::SetProperty(object, name, value, strict_mode)); | 9483 isolate, Object::SetProperty(object, name, value, strict_mode)); |
9482 | 9484 |
9483 return *value; | 9485 return *value; |
9484 } | 9486 } |
(...skipping 19 matching lines...) Expand all Loading... |
9504 SealHandleScope shs(isolate); | 9506 SealHandleScope shs(isolate); |
9505 DCHECK(args.length() == 0); | 9507 DCHECK(args.length() == 0); |
9506 return isolate->PromoteScheduledException(); | 9508 return isolate->PromoteScheduledException(); |
9507 } | 9509 } |
9508 | 9510 |
9509 | 9511 |
9510 RUNTIME_FUNCTION(Runtime_ThrowReferenceError) { | 9512 RUNTIME_FUNCTION(Runtime_ThrowReferenceError) { |
9511 HandleScope scope(isolate); | 9513 HandleScope scope(isolate); |
9512 DCHECK(args.length() == 1); | 9514 DCHECK(args.length() == 1); |
9513 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); | 9515 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); |
9514 Handle<Object> reference_error = | 9516 THROW_NEW_ERROR_RETURN_FAILURE( |
9515 isolate->factory()->NewReferenceError("not_defined", | 9517 isolate, NewReferenceError("not_defined", HandleVector(&name, 1))); |
9516 HandleVector(&name, 1)); | |
9517 return isolate->Throw(*reference_error); | |
9518 } | 9518 } |
9519 | 9519 |
9520 | 9520 |
9521 RUNTIME_FUNCTION(Runtime_ThrowNotDateError) { | 9521 RUNTIME_FUNCTION(Runtime_ThrowNotDateError) { |
9522 HandleScope scope(isolate); | 9522 HandleScope scope(isolate); |
9523 DCHECK(args.length() == 0); | 9523 DCHECK(args.length() == 0); |
9524 return isolate->Throw(*isolate->factory()->NewTypeError( | 9524 THROW_NEW_ERROR_RETURN_FAILURE( |
9525 "not_date_object", HandleVector<Object>(NULL, 0))); | 9525 isolate, NewTypeError("not_date_object", HandleVector<Object>(NULL, 0))); |
9526 } | 9526 } |
9527 | 9527 |
9528 | 9528 |
9529 RUNTIME_FUNCTION(Runtime_StackGuard) { | 9529 RUNTIME_FUNCTION(Runtime_StackGuard) { |
9530 SealHandleScope shs(isolate); | 9530 SealHandleScope shs(isolate); |
9531 DCHECK(args.length() == 0); | 9531 DCHECK(args.length() == 0); |
9532 | 9532 |
9533 // First check if this is a real stack overflow. | 9533 // First check if this is a real stack overflow. |
9534 StackLimitCheck check(isolate); | 9534 StackLimitCheck check(isolate); |
9535 if (check.JsHasOverflowed()) { | 9535 if (check.JsHasOverflowed()) { |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9873 if (!TokensMatchForCompileString(isolate)) { | 9873 if (!TokensMatchForCompileString(isolate)) { |
9874 return isolate->heap()->undefined_value(); | 9874 return isolate->heap()->undefined_value(); |
9875 } | 9875 } |
9876 | 9876 |
9877 // Check if native context allows code generation from | 9877 // Check if native context allows code generation from |
9878 // strings. Throw an exception if it doesn't. | 9878 // strings. Throw an exception if it doesn't. |
9879 if (context->allow_code_gen_from_strings()->IsFalse() && | 9879 if (context->allow_code_gen_from_strings()->IsFalse() && |
9880 !CodeGenerationFromStringsAllowed(isolate, context)) { | 9880 !CodeGenerationFromStringsAllowed(isolate, context)) { |
9881 Handle<Object> error_message = | 9881 Handle<Object> error_message = |
9882 context->ErrorMessageForCodeGenerationFromStrings(); | 9882 context->ErrorMessageForCodeGenerationFromStrings(); |
9883 return isolate->Throw(*isolate->factory()->NewEvalError( | 9883 THROW_NEW_ERROR_RETURN_FAILURE( |
9884 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); | 9884 isolate, NewEvalError("code_gen_from_strings", |
| 9885 HandleVector<Object>(&error_message, 1))); |
9885 } | 9886 } |
9886 | 9887 |
9887 // Compile source string in the native context. | 9888 // Compile source string in the native context. |
9888 ParseRestriction restriction = function_literal_only | 9889 ParseRestriction restriction = function_literal_only |
9889 ? ONLY_SINGLE_FUNCTION_LITERAL : NO_PARSE_RESTRICTION; | 9890 ? ONLY_SINGLE_FUNCTION_LITERAL : NO_PARSE_RESTRICTION; |
9890 Handle<JSFunction> fun; | 9891 Handle<JSFunction> fun; |
9891 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 9892 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
9892 isolate, fun, | 9893 isolate, fun, |
9893 Compiler::GetFunctionFromEval( | 9894 Compiler::GetFunctionFromEval( |
9894 source, context, SLOPPY, restriction, RelocInfo::kNoPosition)); | 9895 source, context, SLOPPY, restriction, RelocInfo::kNoPosition)); |
9895 return *fun; | 9896 return *fun; |
9896 } | 9897 } |
9897 | 9898 |
9898 | 9899 |
9899 static ObjectPair CompileGlobalEval(Isolate* isolate, | 9900 static ObjectPair CompileGlobalEval(Isolate* isolate, |
9900 Handle<String> source, | 9901 Handle<String> source, |
9901 Handle<Object> receiver, | 9902 Handle<Object> receiver, |
9902 StrictMode strict_mode, | 9903 StrictMode strict_mode, |
9903 int scope_position) { | 9904 int scope_position) { |
9904 Handle<Context> context = Handle<Context>(isolate->context()); | 9905 Handle<Context> context = Handle<Context>(isolate->context()); |
9905 Handle<Context> native_context = Handle<Context>(context->native_context()); | 9906 Handle<Context> native_context = Handle<Context>(context->native_context()); |
9906 | 9907 |
9907 // Check if native context allows code generation from | 9908 // Check if native context allows code generation from |
9908 // strings. Throw an exception if it doesn't. | 9909 // strings. Throw an exception if it doesn't. |
9909 if (native_context->allow_code_gen_from_strings()->IsFalse() && | 9910 if (native_context->allow_code_gen_from_strings()->IsFalse() && |
9910 !CodeGenerationFromStringsAllowed(isolate, native_context)) { | 9911 !CodeGenerationFromStringsAllowed(isolate, native_context)) { |
9911 Handle<Object> error_message = | 9912 Handle<Object> error_message = |
9912 native_context->ErrorMessageForCodeGenerationFromStrings(); | 9913 native_context->ErrorMessageForCodeGenerationFromStrings(); |
9913 isolate->Throw(*isolate->factory()->NewEvalError( | 9914 Handle<Object> error; |
9914 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); | 9915 MaybeHandle<Object> maybe_error = isolate->factory()->NewEvalError( |
| 9916 "code_gen_from_strings", HandleVector<Object>(&error_message, 1)); |
| 9917 if (maybe_error.ToHandle(&error)) isolate->Throw(*error); |
9915 return MakePair(isolate->heap()->exception(), NULL); | 9918 return MakePair(isolate->heap()->exception(), NULL); |
9916 } | 9919 } |
9917 | 9920 |
9918 // Deal with a normal eval call with a string argument. Compile it | 9921 // Deal with a normal eval call with a string argument. Compile it |
9919 // and return the compiled function bound in the local context. | 9922 // and return the compiled function bound in the local context. |
9920 static const ParseRestriction restriction = NO_PARSE_RESTRICTION; | 9923 static const ParseRestriction restriction = NO_PARSE_RESTRICTION; |
9921 Handle<JSFunction> compiled; | 9924 Handle<JSFunction> compiled; |
9922 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 9925 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
9923 isolate, compiled, | 9926 isolate, compiled, |
9924 Compiler::GetFunctionFromEval( | 9927 Compiler::GetFunctionFromEval( |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10682 if (!IterateElements(isolate, array, &visitor)) { | 10685 if (!IterateElements(isolate, array, &visitor)) { |
10683 return isolate->heap()->exception(); | 10686 return isolate->heap()->exception(); |
10684 } | 10687 } |
10685 } else { | 10688 } else { |
10686 visitor.visit(0, obj); | 10689 visitor.visit(0, obj); |
10687 visitor.increase_index_offset(1); | 10690 visitor.increase_index_offset(1); |
10688 } | 10691 } |
10689 } | 10692 } |
10690 | 10693 |
10691 if (visitor.exceeds_array_limit()) { | 10694 if (visitor.exceeds_array_limit()) { |
10692 return isolate->Throw( | 10695 THROW_NEW_ERROR_RETURN_FAILURE( |
10693 *isolate->factory()->NewRangeError("invalid_array_length", | 10696 isolate, |
10694 HandleVector<Object>(NULL, 0))); | 10697 NewRangeError("invalid_array_length", HandleVector<Object>(NULL, 0))); |
10695 } | 10698 } |
10696 return *visitor.ToArray(); | 10699 return *visitor.ToArray(); |
10697 } | 10700 } |
10698 | 10701 |
10699 | 10702 |
10700 // This will not allocate (flatten the string), but it may run | 10703 // This will not allocate (flatten the string), but it may run |
10701 // very slowly for very deeply nested ConsStrings. For debugging use only. | 10704 // very slowly for very deeply nested ConsStrings. For debugging use only. |
10702 RUNTIME_FUNCTION(Runtime_GlobalPrint) { | 10705 RUNTIME_FUNCTION(Runtime_GlobalPrint) { |
10703 SealHandleScope shs(isolate); | 10706 SealHandleScope shs(isolate); |
10704 DCHECK(args.length() == 1); | 10707 DCHECK(args.length() == 1); |
(...skipping 3324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14029 | 14032 |
14030 RUNTIME_FUNCTION(Runtime_GetImplFromInitializedIntlObject) { | 14033 RUNTIME_FUNCTION(Runtime_GetImplFromInitializedIntlObject) { |
14031 HandleScope scope(isolate); | 14034 HandleScope scope(isolate); |
14032 | 14035 |
14033 DCHECK(args.length() == 1); | 14036 DCHECK(args.length() == 1); |
14034 | 14037 |
14035 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 14038 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
14036 | 14039 |
14037 if (!input->IsJSObject()) { | 14040 if (!input->IsJSObject()) { |
14038 Vector< Handle<Object> > arguments = HandleVector(&input, 1); | 14041 Vector< Handle<Object> > arguments = HandleVector(&input, 1); |
14039 Handle<Object> type_error = | 14042 THROW_NEW_ERROR_RETURN_FAILURE(isolate, |
14040 isolate->factory()->NewTypeError("not_intl_object", arguments); | 14043 NewTypeError("not_intl_object", arguments)); |
14041 return isolate->Throw(*type_error); | |
14042 } | 14044 } |
14043 | 14045 |
14044 Handle<JSObject> obj = Handle<JSObject>::cast(input); | 14046 Handle<JSObject> obj = Handle<JSObject>::cast(input); |
14045 | 14047 |
14046 Handle<String> marker = isolate->factory()->intl_impl_object_string(); | 14048 Handle<String> marker = isolate->factory()->intl_impl_object_string(); |
14047 Handle<Object> impl(obj->GetHiddenProperty(marker), isolate); | 14049 Handle<Object> impl(obj->GetHiddenProperty(marker), isolate); |
14048 if (impl->IsTheHole()) { | 14050 if (impl->IsTheHole()) { |
14049 Vector< Handle<Object> > arguments = HandleVector(&obj, 1); | 14051 Vector< Handle<Object> > arguments = HandleVector(&obj, 1); |
14050 Handle<Object> type_error = | 14052 THROW_NEW_ERROR_RETURN_FAILURE(isolate, |
14051 isolate->factory()->NewTypeError("not_intl_object", arguments); | 14053 NewTypeError("not_intl_object", arguments)); |
14052 return isolate->Throw(*type_error); | |
14053 } | 14054 } |
14054 return *impl; | 14055 return *impl; |
14055 } | 14056 } |
14056 | 14057 |
14057 | 14058 |
14058 RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) { | 14059 RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) { |
14059 HandleScope scope(isolate); | 14060 HandleScope scope(isolate); |
14060 | 14061 |
14061 DCHECK(args.length() == 3); | 14062 DCHECK(args.length() == 3); |
14062 | 14063 |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15364 } | 15365 } |
15365 | 15366 |
15366 | 15367 |
15367 RUNTIME_FUNCTION(RuntimeReference_DateField) { | 15368 RUNTIME_FUNCTION(RuntimeReference_DateField) { |
15368 SealHandleScope shs(isolate); | 15369 SealHandleScope shs(isolate); |
15369 DCHECK(args.length() == 2); | 15370 DCHECK(args.length() == 2); |
15370 CONVERT_ARG_CHECKED(Object, obj, 0); | 15371 CONVERT_ARG_CHECKED(Object, obj, 0); |
15371 CONVERT_SMI_ARG_CHECKED(index, 1); | 15372 CONVERT_SMI_ARG_CHECKED(index, 1); |
15372 if (!obj->IsJSDate()) { | 15373 if (!obj->IsJSDate()) { |
15373 HandleScope scope(isolate); | 15374 HandleScope scope(isolate); |
15374 return isolate->Throw(*isolate->factory()->NewTypeError( | 15375 THROW_NEW_ERROR_RETURN_FAILURE( |
15375 "not_date_object", HandleVector<Object>(NULL, 0))); | 15376 isolate, |
| 15377 NewTypeError("not_date_object", HandleVector<Object>(NULL, 0))); |
15376 } | 15378 } |
15377 JSDate* date = JSDate::cast(obj); | 15379 JSDate* date = JSDate::cast(obj); |
15378 if (index == 0) return date->value(); | 15380 if (index == 0) return date->value(); |
15379 return JSDate::GetField(date, Smi::FromInt(index)); | 15381 return JSDate::GetField(date, Smi::FromInt(index)); |
15380 } | 15382 } |
15381 | 15383 |
15382 | 15384 |
15383 RUNTIME_FUNCTION(RuntimeReference_StringCharFromCode) { | 15385 RUNTIME_FUNCTION(RuntimeReference_StringCharFromCode) { |
15384 SealHandleScope shs(isolate); | 15386 SealHandleScope shs(isolate); |
15385 return __RT_impl_Runtime_CharFromCode(args, isolate); | 15387 return __RT_impl_Runtime_CharFromCode(args, isolate); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15652 } | 15654 } |
15653 return NULL; | 15655 return NULL; |
15654 } | 15656 } |
15655 | 15657 |
15656 | 15658 |
15657 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15659 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15658 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15660 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15659 } | 15661 } |
15660 | 15662 |
15661 } } // namespace v8::internal | 15663 } } // namespace v8::internal |
OLD | NEW |