OLD | NEW |
---|---|
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 | 4 |
5 #include <limits.h> | 5 #include <limits.h> |
6 #include <stddef.h> | 6 #include <stddef.h> |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "include/v8.h" | 9 #include "include/v8.h" |
10 #include "src/factory.h" | 10 #include "src/factory.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 const i::uc16 two_byte_array[6] = {'f', 0xD83D, 0xDCA9, 'b', 'a', 0x2603}; | 50 const i::uc16 two_byte_array[6] = {'f', 0xD83D, 0xDCA9, 'b', 'a', 0x2603}; |
51 | 51 |
52 i::Handle<i::RegExpMatchInfo> results_array = factory->NewRegExpMatchInfo(); | 52 i::Handle<i::RegExpMatchInfo> results_array = factory->NewRegExpMatchInfo(); |
53 i::Handle<i::String> one_byte = | 53 i::Handle<i::String> one_byte = |
54 factory->NewStringFromOneByte(i::Vector<const uint8_t>(one_byte_array, 6)) | 54 factory->NewStringFromOneByte(i::Vector<const uint8_t>(one_byte_array, 6)) |
55 .ToHandleChecked(); | 55 .ToHandleChecked(); |
56 i::Handle<i::String> two_byte = | 56 i::Handle<i::String> two_byte = |
57 factory->NewStringFromTwoByte(i::Vector<const i::uc16>(two_byte_array, 6)) | 57 factory->NewStringFromTwoByte(i::Vector<const i::uc16>(two_byte_array, 6)) |
58 .ToHandleChecked(); | 58 .ToHandleChecked(); |
59 | 59 |
60 for (int flags = 0; flags <= kAllFlags; flags++) { | 60 i::Handle<i::JSRegExp> regexp; |
61 i::Handle<i::JSRegExp> regexp; | 61 { |
62 { | 62 v8::TryCatch try_catch(isolate); |
63 v8::TryCatch try_catch(isolate); | 63 // Create a string so that we can calculate a hash from the input data. |
64 i::MaybeHandle<i::JSRegExp> maybe_regexp = | 64 std::string str = std::string(reinterpret_cast<const char*>(data), size); |
65 i::JSRegExp::New(source, static_cast<i::JSRegExp::Flags>(flags)); | 65 i::JSRegExp::Flags flag = static_cast<i::JSRegExp::Flags>( |
66 if (!maybe_regexp.ToHandle(®exp)) { | 66 std::hash<std::string>()(str) % (kAllFlags + 1)); |
67 i_isolate->clear_pending_exception(); | 67 i::MaybeHandle<i::JSRegExp> maybe_regexp = i::JSRegExp::New(source, flag); |
68 continue; | 68 if (!maybe_regexp.ToHandle(®exp)) { |
69 } | 69 i_isolate->clear_pending_exception(); |
70 return 0; | |
70 } | 71 } |
71 Test(isolate, regexp, one_byte, results_array); | |
72 Test(isolate, regexp, two_byte, results_array); | |
73 Test(isolate, regexp, factory->empty_string(), results_array); | |
74 Test(isolate, regexp, source, results_array); | |
75 } | 72 } |
76 | 73 Test(isolate, regexp, one_byte, results_array); |
77 isolate->RequestGarbageCollectionForTesting( | 74 Test(isolate, regexp, two_byte, results_array); |
mmoroz
2016/11/22 10:46:38
Could you please return this call?
ahaas
2016/11/22 12:30:56
Done.
| |
78 v8::Isolate::kFullGarbageCollection); | 75 Test(isolate, regexp, factory->empty_string(), results_array); |
76 Test(isolate, regexp, source, results_array); | |
79 return 0; | 77 return 0; |
80 } | 78 } |
OLD | NEW |