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

Side by Side Diff: src/bootstrapper.cc

Issue 1070093002: Eagerly escape RegExp.source. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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/accessors.cc ('k') | src/objects.h » ('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/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/extensions/externalize-string-extension.h" 10 #include "src/extensions/externalize-string-extension.h"
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 Handle<Map> initial_map(regexp_fun->initial_map()); 1059 Handle<Map> initial_map(regexp_fun->initial_map());
1060 1060
1061 DCHECK_EQ(0, initial_map->inobject_properties()); 1061 DCHECK_EQ(0, initial_map->inobject_properties());
1062 1062
1063 PropertyAttributes final = 1063 PropertyAttributes final =
1064 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 1064 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1065 Map::EnsureDescriptorSlack(initial_map, 5); 1065 Map::EnsureDescriptorSlack(initial_map, 5);
1066 1066
1067 { 1067 {
1068 // ECMA-262, section 15.10.7.1. 1068 // ECMA-262, section 15.10.7.1.
1069 Handle<AccessorInfo> regexp_source( 1069 DataDescriptor field(factory->source_string(),
1070 Accessors::RegExpSourceInfo(isolate, final)); 1070 JSRegExp::kSourceFieldIndex, final,
1071 AccessorConstantDescriptor d(factory->source_string(), regexp_source, 1071 Representation::Tagged());
1072 final); 1072 initial_map->AppendDescriptor(&field);
1073 initial_map->AppendDescriptor(&d);
1074 } 1073 }
1075 { 1074 {
1076 // ECMA-262, section 15.10.7.2. 1075 // ECMA-262, section 15.10.7.2.
1077 DataDescriptor field(factory->global_string(), 1076 DataDescriptor field(factory->global_string(),
1078 JSRegExp::kGlobalFieldIndex, final, 1077 JSRegExp::kGlobalFieldIndex, final,
1079 Representation::Tagged()); 1078 Representation::Tagged());
1080 initial_map->AppendDescriptor(&field); 1079 initial_map->AppendDescriptor(&field);
1081 } 1080 }
1082 { 1081 {
1083 // ECMA-262, section 15.10.7.3. 1082 // ECMA-262, section 15.10.7.3.
(...skipping 23 matching lines...) Expand all
1107 initial_map->set_inobject_properties(num_fields); 1106 initial_map->set_inobject_properties(num_fields);
1108 initial_map->set_pre_allocated_property_fields(num_fields); 1107 initial_map->set_pre_allocated_property_fields(num_fields);
1109 initial_map->set_unused_property_fields(0); 1108 initial_map->set_unused_property_fields(0);
1110 initial_map->set_instance_size(initial_map->instance_size() + 1109 initial_map->set_instance_size(initial_map->instance_size() +
1111 num_fields * kPointerSize); 1110 num_fields * kPointerSize);
1112 1111
1113 // RegExp prototype object is itself a RegExp. 1112 // RegExp prototype object is itself a RegExp.
1114 Handle<Map> proto_map = Map::Copy(initial_map, "RegExpPrototype"); 1113 Handle<Map> proto_map = Map::Copy(initial_map, "RegExpPrototype");
1115 DCHECK(proto_map->prototype() == *isolate->initial_object_prototype()); 1114 DCHECK(proto_map->prototype() == *isolate->initial_object_prototype());
1116 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map); 1115 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map);
1116 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex,
1117 heap->query_colon_string());
1117 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, 1118 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex,
1118 heap->false_value()); 1119 heap->false_value());
1119 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, 1120 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex,
1120 heap->false_value()); 1121 heap->false_value());
1121 proto->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex, 1122 proto->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex,
1122 heap->false_value()); 1123 heap->false_value());
1123 proto->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex, 1124 proto->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex,
1124 Smi::FromInt(0), 1125 Smi::FromInt(0),
1125 SKIP_WRITE_BARRIER); // It's a Smi. 1126 SKIP_WRITE_BARRIER); // It's a Smi.
1126 proto_map->set_is_prototype_map(true); 1127 proto_map->set_is_prototype_map(true);
(...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after
2963 return from + sizeof(NestingCounterType); 2964 return from + sizeof(NestingCounterType);
2964 } 2965 }
2965 2966
2966 2967
2967 // Called when the top-level V8 mutex is destroyed. 2968 // Called when the top-level V8 mutex is destroyed.
2968 void Bootstrapper::FreeThreadResources() { 2969 void Bootstrapper::FreeThreadResources() {
2969 DCHECK(!IsActive()); 2970 DCHECK(!IsActive());
2970 } 2971 }
2971 2972
2972 } } // namespace v8::internal 2973 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698