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

Side by Side Diff: src/code-stub-assembler.cc

Issue 2863643004: [regexp] Avoid runtime call on OOB lastIndex values (Closed)
Patch Set: Add IsNumberPositive assert Created 3 years, 7 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/code-stub-assembler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 #include "src/code-stub-assembler.h" 4 #include "src/code-stub-assembler.h"
5 #include "src/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/frames-inl.h" 6 #include "src/frames-inl.h"
7 #include "src/frames.h" 7 #include "src/frames.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 3323 matching lines...) Expand 10 before | Expand all | Expand 10 after
3334 GotoIf(Float64GreaterThan(value, smi_max), &out); 3334 GotoIf(Float64GreaterThan(value, smi_max), &out);
3335 GotoIfNot(Float64Equal(value, value), &out); // NaN. 3335 GotoIfNot(Float64Equal(value, value), &out); // NaN.
3336 3336
3337 var_result.Bind(Int32Constant(0)); 3337 var_result.Bind(Int32Constant(0));
3338 Goto(&out); 3338 Goto(&out);
3339 3339
3340 BIND(&out); 3340 BIND(&out);
3341 return var_result.value(); 3341 return var_result.value();
3342 } 3342 }
3343 3343
3344 Node* CodeStubAssembler::IsNumberPositive(Node* number) {
3345 CSA_ASSERT(this, IsNumber(number));
3346 Node* const float_zero = Float64Constant(0.);
3347 return Select(TaggedIsSmi(number),
3348 [=] { return TaggedIsPositiveSmi(number); },
3349 [=] {
3350 Node* v = LoadHeapNumberValue(number);
3351 return Float64GreaterThanOrEqual(v, float_zero);
3352 },
3353 MachineRepresentation::kWord32);
3354 }
3355
3344 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index, 3356 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index,
3345 ParameterMode parameter_mode) { 3357 ParameterMode parameter_mode) {
3346 if (parameter_mode == SMI_PARAMETERS) CSA_ASSERT(this, TaggedIsSmi(index)); 3358 if (parameter_mode == SMI_PARAMETERS) CSA_ASSERT(this, TaggedIsSmi(index));
3347 CSA_ASSERT(this, IsString(string)); 3359 CSA_ASSERT(this, IsString(string));
3348 3360
3349 // Translate the {index} into a Word. 3361 // Translate the {index} into a Word.
3350 Node* const int_index = ParameterToWord(index, parameter_mode); 3362 Node* const int_index = ParameterToWord(index, parameter_mode);
3351 CSA_ASSERT(this, IntPtrGreaterThanOrEqual(int_index, IntPtrConstant(0))); 3363 CSA_ASSERT(this, IntPtrGreaterThanOrEqual(int_index, IntPtrConstant(0)));
3352 3364
3353 VARIABLE(var_result, MachineRepresentation::kWord32); 3365 VARIABLE(var_result, MachineRepresentation::kWord32);
(...skipping 5532 matching lines...) Expand 10 before | Expand all | Expand 10 after
8886 formatted.c_str(), TENURED); 8898 formatted.c_str(), TENURED);
8887 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), 8899 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(),
8888 HeapConstant(string)); 8900 HeapConstant(string));
8889 } 8901 }
8890 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); 8902 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value);
8891 #endif 8903 #endif
8892 } 8904 }
8893 8905
8894 } // namespace internal 8906 } // namespace internal
8895 } // namespace v8 8907 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698