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 7151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7162 position += increment; | 7162 position += increment; |
7163 } | 7163 } |
7164 return position; | 7164 return position; |
7165 } | 7165 } |
7166 | 7166 |
7167 | 7167 |
7168 RUNTIME_FUNCTION(Runtime_StringBuilderConcat) { | 7168 RUNTIME_FUNCTION(Runtime_StringBuilderConcat) { |
7169 HandleScope scope(isolate); | 7169 HandleScope scope(isolate); |
7170 DCHECK(args.length() == 3); | 7170 DCHECK(args.length() == 3); |
7171 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 7171 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
7172 if (!args[1]->IsSmi()) { | 7172 int32_t array_length; |
| 7173 if (!args[1]->ToInt32(&array_length)) { |
7173 THROW_NEW_ERROR_RETURN_FAILURE(isolate, NewInvalidStringLengthError()); | 7174 THROW_NEW_ERROR_RETURN_FAILURE(isolate, NewInvalidStringLengthError()); |
7174 } | 7175 } |
7175 CONVERT_SMI_ARG_CHECKED(array_length, 1); | |
7176 CONVERT_ARG_HANDLE_CHECKED(String, special, 2); | 7176 CONVERT_ARG_HANDLE_CHECKED(String, special, 2); |
7177 | 7177 |
7178 size_t actual_array_length = 0; | 7178 size_t actual_array_length = 0; |
7179 RUNTIME_ASSERT( | 7179 RUNTIME_ASSERT( |
7180 TryNumberToSize(isolate, array->length(), &actual_array_length)); | 7180 TryNumberToSize(isolate, array->length(), &actual_array_length)); |
7181 RUNTIME_ASSERT(array_length >= 0); | 7181 RUNTIME_ASSERT(array_length >= 0); |
7182 RUNTIME_ASSERT(static_cast<size_t>(array_length) <= actual_array_length); | 7182 RUNTIME_ASSERT(static_cast<size_t>(array_length) <= actual_array_length); |
7183 | 7183 |
7184 // This assumption is used by the slice encoding in one or two smis. | 7184 // This assumption is used by the slice encoding in one or two smis. |
7185 DCHECK(Smi::kMaxValue >= String::kMaxLength); | 7185 DCHECK(Smi::kMaxValue >= String::kMaxLength); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7236 array_length); | 7236 array_length); |
7237 return *answer; | 7237 return *answer; |
7238 } | 7238 } |
7239 } | 7239 } |
7240 | 7240 |
7241 | 7241 |
7242 RUNTIME_FUNCTION(Runtime_StringBuilderJoin) { | 7242 RUNTIME_FUNCTION(Runtime_StringBuilderJoin) { |
7243 HandleScope scope(isolate); | 7243 HandleScope scope(isolate); |
7244 DCHECK(args.length() == 3); | 7244 DCHECK(args.length() == 3); |
7245 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 7245 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
7246 if (!args[1]->IsSmi()) { | 7246 int32_t array_length; |
| 7247 if (!args[1]->ToInt32(&array_length)) { |
7247 THROW_NEW_ERROR_RETURN_FAILURE(isolate, NewInvalidStringLengthError()); | 7248 THROW_NEW_ERROR_RETURN_FAILURE(isolate, NewInvalidStringLengthError()); |
7248 } | 7249 } |
7249 CONVERT_SMI_ARG_CHECKED(array_length, 1); | |
7250 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); | 7250 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); |
7251 RUNTIME_ASSERT(array->HasFastObjectElements()); | 7251 RUNTIME_ASSERT(array->HasFastObjectElements()); |
7252 RUNTIME_ASSERT(array_length >= 0); | 7252 RUNTIME_ASSERT(array_length >= 0); |
7253 | 7253 |
7254 Handle<FixedArray> fixed_array(FixedArray::cast(array->elements())); | 7254 Handle<FixedArray> fixed_array(FixedArray::cast(array->elements())); |
7255 if (fixed_array->length() < array_length) { | 7255 if (fixed_array->length() < array_length) { |
7256 array_length = fixed_array->length(); | 7256 array_length = fixed_array->length(); |
7257 } | 7257 } |
7258 | 7258 |
7259 if (array_length == 0) { | 7259 if (array_length == 0) { |
(...skipping 8418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15678 } | 15678 } |
15679 return NULL; | 15679 return NULL; |
15680 } | 15680 } |
15681 | 15681 |
15682 | 15682 |
15683 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15683 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15684 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15684 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15685 } | 15685 } |
15686 | 15686 |
15687 } } // namespace v8::internal | 15687 } } // namespace v8::internal |
OLD | NEW |