OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 15407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15418 Isolate* isolate = regexp->GetIsolate(); | 15418 Isolate* isolate = regexp->GetIsolate(); |
15419 Factory* factory = isolate->factory(); | 15419 Factory* factory = isolate->factory(); |
15420 // If source is the empty string we set it to "(?:)" instead as | 15420 // If source is the empty string we set it to "(?:)" instead as |
15421 // suggested by ECMA-262, 5th, section 15.10.4.1. | 15421 // suggested by ECMA-262, 5th, section 15.10.4.1. |
15422 if (source->length() == 0) source = factory->query_colon_string(); | 15422 if (source->length() == 0) source = factory->query_colon_string(); |
15423 | 15423 |
15424 Handle<String> escaped_source; | 15424 Handle<String> escaped_source; |
15425 ASSIGN_RETURN_ON_EXCEPTION(isolate, escaped_source, | 15425 ASSIGN_RETURN_ON_EXCEPTION(isolate, escaped_source, |
15426 EscapeRegExpSource(isolate, source), JSRegExp); | 15426 EscapeRegExpSource(isolate, source), JSRegExp); |
15427 | 15427 |
| 15428 RETURN_ON_EXCEPTION(isolate, RegExpImpl::Compile(regexp, source, flags), |
| 15429 JSRegExp); |
| 15430 |
15428 regexp->set_source(*escaped_source); | 15431 regexp->set_source(*escaped_source); |
15429 regexp->set_flags(Smi::FromInt(flags)); | 15432 regexp->set_flags(Smi::FromInt(flags)); |
15430 | 15433 |
15431 Map* map = regexp->map(); | 15434 Map* map = regexp->map(); |
15432 Object* constructor = map->GetConstructor(); | 15435 Object* constructor = map->GetConstructor(); |
15433 if (constructor->IsJSFunction() && | 15436 if (constructor->IsJSFunction() && |
15434 JSFunction::cast(constructor)->initial_map() == map) { | 15437 JSFunction::cast(constructor)->initial_map() == map) { |
15435 // If we still have the original map, set in-object properties directly. | 15438 // If we still have the original map, set in-object properties directly. |
15436 regexp->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex, | 15439 regexp->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex, |
15437 Smi::FromInt(0), SKIP_WRITE_BARRIER); | 15440 Smi::FromInt(0), SKIP_WRITE_BARRIER); |
15438 } else { | 15441 } else { |
15439 // Map has changed, so use generic, but slower, method. | 15442 // Map has changed, so use generic, but slower, method. |
15440 PropertyAttributes writable = | 15443 PropertyAttributes writable = |
15441 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); | 15444 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
15442 JSObject::SetOwnPropertyIgnoreAttributes( | 15445 JSObject::SetOwnPropertyIgnoreAttributes( |
15443 regexp, factory->last_index_string(), | 15446 regexp, factory->last_index_string(), |
15444 Handle<Smi>(Smi::FromInt(0), isolate), writable) | 15447 Handle<Smi>(Smi::FromInt(0), isolate), writable) |
15445 .Check(); | 15448 .Check(); |
15446 } | 15449 } |
15447 | 15450 |
15448 RETURN_ON_EXCEPTION(isolate, RegExpImpl::Compile(regexp, source, flags), | |
15449 JSRegExp); | |
15450 | |
15451 return regexp; | 15451 return regexp; |
15452 } | 15452 } |
15453 | 15453 |
15454 | 15454 |
15455 // RegExpKey carries the source and flags of a regular expression as key. | 15455 // RegExpKey carries the source and flags of a regular expression as key. |
15456 class RegExpKey : public HashTableKey { | 15456 class RegExpKey : public HashTableKey { |
15457 public: | 15457 public: |
15458 RegExpKey(Handle<String> string, JSRegExp::Flags flags) | 15458 RegExpKey(Handle<String> string, JSRegExp::Flags flags) |
15459 : string_(string), flags_(Smi::FromInt(flags)) {} | 15459 : string_(string), flags_(Smi::FromInt(flags)) {} |
15460 | 15460 |
(...skipping 2814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18275 if (cell->value() != *new_value) { | 18275 if (cell->value() != *new_value) { |
18276 cell->set_value(*new_value); | 18276 cell->set_value(*new_value); |
18277 Isolate* isolate = cell->GetIsolate(); | 18277 Isolate* isolate = cell->GetIsolate(); |
18278 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 18278 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
18279 isolate, DependentCode::kPropertyCellChangedGroup); | 18279 isolate, DependentCode::kPropertyCellChangedGroup); |
18280 } | 18280 } |
18281 } | 18281 } |
18282 | 18282 |
18283 } // namespace internal | 18283 } // namespace internal |
18284 } // namespace v8 | 18284 } // namespace v8 |
OLD | NEW |