OLD | NEW |
1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 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/builtins/builtins-regexp-gen.h" | 5 #include "src/builtins/builtins-regexp-gen.h" |
6 | 6 |
7 #include "src/builtins/builtins-constructor-gen.h" | 7 #include "src/builtins/builtins-constructor-gen.h" |
8 #include "src/builtins/builtins-utils-gen.h" | 8 #include "src/builtins/builtins-utils-gen.h" |
9 #include "src/builtins/builtins.h" | 9 #include "src/builtins/builtins.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 #ifdef V8_INTERPRETED_REGEXP | 243 #ifdef V8_INTERPRETED_REGEXP |
244 return CallRuntime(Runtime::kRegExpExec, context, regexp, string, last_index, | 244 return CallRuntime(Runtime::kRegExpExec, context, regexp, string, last_index, |
245 match_info); | 245 match_info); |
246 #else // V8_INTERPRETED_REGEXP | 246 #else // V8_INTERPRETED_REGEXP |
247 CSA_ASSERT(this, TaggedIsNotSmi(regexp)); | 247 CSA_ASSERT(this, TaggedIsNotSmi(regexp)); |
248 CSA_ASSERT(this, IsJSRegExp(regexp)); | 248 CSA_ASSERT(this, IsJSRegExp(regexp)); |
249 | 249 |
250 CSA_ASSERT(this, TaggedIsNotSmi(string)); | 250 CSA_ASSERT(this, TaggedIsNotSmi(string)); |
251 CSA_ASSERT(this, IsString(string)); | 251 CSA_ASSERT(this, IsString(string)); |
252 | 252 |
253 CSA_ASSERT(this, IsHeapNumberMap(LoadReceiverMap(last_index))); | 253 CSA_ASSERT(this, IsNumber(last_index)); |
254 CSA_ASSERT(this, IsFixedArrayMap(LoadReceiverMap(match_info))); | 254 CSA_ASSERT(this, IsFixedArrayMap(LoadReceiverMap(match_info))); |
255 | 255 |
256 Node* const int_zero = IntPtrConstant(0); | 256 Node* const int_zero = IntPtrConstant(0); |
257 | 257 |
258 ToDirectStringAssembler to_direct(state(), string); | 258 ToDirectStringAssembler to_direct(state(), string); |
259 | 259 |
260 VARIABLE(var_result, MachineRepresentation::kTagged); | 260 VARIABLE(var_result, MachineRepresentation::kTagged); |
261 Label out(this), runtime(this, Label::kDeferred); | 261 Label out(this), runtime(this, Label::kDeferred); |
262 | 262 |
263 // External constants. | 263 // External constants. |
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 SelectBooleanConstant(WordNotEqual(match_indices, NullConstant())); | 1525 SelectBooleanConstant(WordNotEqual(match_indices, NullConstant())); |
1526 Return(result); | 1526 Return(result); |
1527 } | 1527 } |
1528 } | 1528 } |
1529 | 1529 |
1530 Node* RegExpBuiltinsAssembler::AdvanceStringIndex(Node* const string, | 1530 Node* RegExpBuiltinsAssembler::AdvanceStringIndex(Node* const string, |
1531 Node* const index, | 1531 Node* const index, |
1532 Node* const is_unicode, | 1532 Node* const is_unicode, |
1533 bool is_fastpath) { | 1533 bool is_fastpath) { |
1534 CSA_ASSERT(this, IsString(string)); | 1534 CSA_ASSERT(this, IsString(string)); |
1535 CSA_ASSERT(this, IsHeapNumberMap(LoadReceiverMap(index))); | 1535 CSA_ASSERT(this, IsNumberNormalized(index)); |
1536 if (is_fastpath) CSA_ASSERT(this, TaggedIsPositiveSmi(index)); | 1536 if (is_fastpath) CSA_ASSERT(this, TaggedIsPositiveSmi(index)); |
1537 | 1537 |
1538 // Default to last_index + 1. | 1538 // Default to last_index + 1. |
1539 // Smi range. | |
1540 | |
1541 // Default to last_index + 1. | |
1542 Node* const index_plus_one = NumberInc(index); | 1539 Node* const index_plus_one = NumberInc(index); |
1543 VARIABLE(var_result, MachineRepresentation::kTagged, index_plus_one); | 1540 VARIABLE(var_result, MachineRepresentation::kTagged, index_plus_one); |
1544 | 1541 |
1545 // Advancing the index has some subtle issues involving the distinction | 1542 // Advancing the index has some subtle issues involving the distinction |
1546 // between Smis and HeapNumbers. There's three cases: | 1543 // between Smis and HeapNumbers. There's three cases: |
1547 // * {index} is a Smi, {index_plus_one} is a Smi. The standard case. | 1544 // * {index} is a Smi, {index_plus_one} is a Smi. The standard case. |
1548 // * {index} is a Smi, {index_plus_one} overflows into a HeapNumber. | 1545 // * {index} is a Smi, {index_plus_one} overflows into a HeapNumber. |
1549 // In this case we can return the result early, because | 1546 // In this case we can return the result early, because |
1550 // {index_plus_one} > {string}.length. | 1547 // {index_plus_one} > {string}.length. |
1551 // * {index} is a HeapNumber, {index_plus_one} is a HeapNumber. This can only | 1548 // * {index} is a HeapNumber, {index_plus_one} is a HeapNumber. This can only |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2349 BIND(&limit_done); | 2346 BIND(&limit_done); |
2350 { | 2347 { |
2351 Node* const limit = var_limit.value(); | 2348 Node* const limit = var_limit.value(); |
2352 RegExpPrototypeSplitBody(context, regexp, string, limit); | 2349 RegExpPrototypeSplitBody(context, regexp, string, limit); |
2353 } | 2350 } |
2354 | 2351 |
2355 Bind(&runtime); | 2352 Bind(&runtime); |
2356 { | 2353 { |
2357 // The runtime call passes in limit to ensure the second ToUint32(limit) | 2354 // The runtime call passes in limit to ensure the second ToUint32(limit) |
2358 // call is not observable. | 2355 // call is not observable. |
2359 CSA_ASSERT(this, IsHeapNumberMap(LoadReceiverMap(limit))); | 2356 CSA_ASSERT(this, IsNumber(limit)); |
2360 Return(CallRuntime(Runtime::kRegExpSplit, context, regexp, string, limit)); | 2357 Return(CallRuntime(Runtime::kRegExpSplit, context, regexp, string, limit)); |
2361 } | 2358 } |
2362 } | 2359 } |
2363 | 2360 |
2364 // ES#sec-regexp.prototype-@@split | 2361 // ES#sec-regexp.prototype-@@split |
2365 // RegExp.prototype [ @@split ] ( string, limit ) | 2362 // RegExp.prototype [ @@split ] ( string, limit ) |
2366 TF_BUILTIN(RegExpPrototypeSplit, RegExpBuiltinsAssembler) { | 2363 TF_BUILTIN(RegExpPrototypeSplit, RegExpBuiltinsAssembler) { |
2367 Node* const maybe_receiver = Parameter(Descriptor::kReceiver); | 2364 Node* const maybe_receiver = Parameter(Descriptor::kReceiver); |
2368 Node* const maybe_string = Parameter(Descriptor::kString); | 2365 Node* const maybe_string = Parameter(Descriptor::kString); |
2369 Node* const maybe_limit = Parameter(Descriptor::kLimit); | 2366 Node* const maybe_limit = Parameter(Descriptor::kLimit); |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2851 BIND(&if_matched); | 2848 BIND(&if_matched); |
2852 { | 2849 { |
2853 Node* result = | 2850 Node* result = |
2854 ConstructNewResultFromMatchInfo(context, regexp, match_indices, string); | 2851 ConstructNewResultFromMatchInfo(context, regexp, match_indices, string); |
2855 Return(result); | 2852 Return(result); |
2856 } | 2853 } |
2857 } | 2854 } |
2858 | 2855 |
2859 } // namespace internal | 2856 } // namespace internal |
2860 } // namespace v8 | 2857 } // namespace v8 |
OLD | NEW |