Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/runtime/runtime-strings.cc

Issue 2122173003: [runtime] Specifically handle robust RUNTIME_ASSERTs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | src/runtime/runtime-test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/regexp/jsregexp-inl.h" 8 #include "src/regexp/jsregexp-inl.h"
9 #include "src/string-builder.h" 9 #include "src/string-builder.h"
10 #include "src/string-search.h" 10 #include "src/string-search.h"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 CONVERT_SMI_ARG_CHECKED(from_number, 1); 291 CONVERT_SMI_ARG_CHECKED(from_number, 1);
292 CONVERT_SMI_ARG_CHECKED(to_number, 2); 292 CONVERT_SMI_ARG_CHECKED(to_number, 2);
293 start = from_number; 293 start = from_number;
294 end = to_number; 294 end = to_number;
295 } else { 295 } else {
296 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); 296 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1);
297 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2); 297 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2);
298 start = FastD2IChecked(from_number); 298 start = FastD2IChecked(from_number);
299 end = FastD2IChecked(to_number); 299 end = FastD2IChecked(to_number);
300 } 300 }
301 RUNTIME_ASSERT(end >= start); 301 // The following condition is intentionally robust because the SubStringStub
302 RUNTIME_ASSERT(start >= 0); 302 // delegates here and we test this in cctest/test-strings/RobustSubStringStub.
303 RUNTIME_ASSERT(end <= string->length()); 303 if (end < start || start < 0 || end > string->length()) {
304 return isolate->ThrowIllegalOperation();
305 }
304 isolate->counters()->sub_string_runtime()->Increment(); 306 isolate->counters()->sub_string_runtime()->Increment();
305 307
306 return *isolate->factory()->NewSubString(string, start, end); 308 return *isolate->factory()->NewSubString(string, start, end);
307 } 309 }
308 310
309 311
310 RUNTIME_FUNCTION(Runtime_StringAdd) { 312 RUNTIME_FUNCTION(Runtime_StringAdd) {
311 HandleScope scope(isolate); 313 HandleScope scope(isolate);
312 DCHECK(args.length() == 2); 314 DCHECK(args.length() == 2);
313 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); 315 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0);
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 SealHandleScope shs(isolate); 1208 SealHandleScope shs(isolate);
1207 DCHECK(args.length() == 2); 1209 DCHECK(args.length() == 2);
1208 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); 1210 if (!args[0]->IsString()) return isolate->heap()->undefined_value();
1209 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); 1211 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value();
1210 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); 1212 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value();
1211 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); 1213 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate);
1212 } 1214 }
1213 1215
1214 } // namespace internal 1216 } // namespace internal
1215 } // namespace v8 1217 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | src/runtime/runtime-test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698