OLD | NEW |
---|---|
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1221 Counters::regexp_entry_runtime.Increment(); | 1221 Counters::regexp_entry_runtime.Increment(); |
1222 Handle<Object> result = RegExpImpl::Exec(regexp, | 1222 Handle<Object> result = RegExpImpl::Exec(regexp, |
1223 subject, | 1223 subject, |
1224 index, | 1224 index, |
1225 last_match_info); | 1225 last_match_info); |
1226 if (result.is_null()) return Failure::Exception(); | 1226 if (result.is_null()) return Failure::Exception(); |
1227 return *result; | 1227 return *result; |
1228 } | 1228 } |
1229 | 1229 |
1230 | 1230 |
1231 static Object* Runtime_RegExpInitializeObject(Arguments args) { | |
1232 AssertNoAllocation no_alloc; | |
1233 ASSERT(args.length() == 5); | |
1234 CONVERT_CHECKED(JSRegExp, regexp, args[0]); | |
1235 CONVERT_CHECKED(String, source, args[1]); | |
1236 | |
1237 Object* global = args[2]; | |
1238 if (!global->IsTrue()) global = Heap::false_value(); | |
1239 | |
1240 Object* ignoreCase = args[3]; | |
1241 if (!ignoreCase->IsTrue()) ignoreCase = Heap::false_value(); | |
1242 | |
1243 Object* multiline = args[4]; | |
1244 if (!multiline->IsTrue()) multiline = Heap::false_value(); | |
1245 | |
1246 Map* map = regexp->map(); | |
1247 Object* constructor = map->constructor(); | |
1248 if (constructor->IsJSFunction() && | |
1249 JSFunction::cast(constructor)->initial_map() == map) { | |
1250 // If we still have the original map, set in-object properties directly. | |
1251 regexp->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, source); | |
1252 // TODO(lrn): Consider skipping write barrier on booleans as well. | |
1253 // Both true and false should be in oldspace at all times. | |
1254 regexp->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, global); | |
1255 regexp->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, ignoreCase); | |
1256 regexp->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex, multiline); | |
1257 regexp->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex, | |
1258 Smi::FromInt(0), | |
1259 SKIP_WRITE_BARRIER); | |
1260 return regexp; | |
1261 } | |
1262 | |
1263 // Map has changed, so use generic, but slower, method. | |
Erik Corry
2010/03/26 13:51:34
This is a strange situation. Do we have a test of
Lasse Reichstein
2010/03/26 14:19:09
I guess the only way this can happen is when using
| |
1264 PropertyAttributes final = | |
1265 static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE); | |
1266 PropertyAttributes writable = | |
1267 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); | |
1268 regexp->IgnoreAttributesAndSetLocalProperty(Heap::source_symbol(), | |
1269 source, | |
1270 final); | |
1271 regexp->IgnoreAttributesAndSetLocalProperty(Heap::global_symbol(), | |
1272 global, | |
1273 final); | |
1274 regexp->IgnoreAttributesAndSetLocalProperty(Heap::ignore_case_symbol(), | |
1275 ignoreCase, | |
1276 final); | |
1277 regexp->IgnoreAttributesAndSetLocalProperty(Heap::multiline_symbol(), | |
1278 multiline, | |
1279 final); | |
1280 regexp->IgnoreAttributesAndSetLocalProperty(Heap::last_index_symbol(), | |
1281 Smi::FromInt(0), | |
1282 writable); | |
1283 return regexp; | |
1284 } | |
1285 | |
1286 | |
1231 static Object* Runtime_FinishArrayPrototypeSetup(Arguments args) { | 1287 static Object* Runtime_FinishArrayPrototypeSetup(Arguments args) { |
1232 HandleScope scope; | 1288 HandleScope scope; |
1233 ASSERT(args.length() == 1); | 1289 ASSERT(args.length() == 1); |
1234 CONVERT_ARG_CHECKED(JSArray, prototype, 0); | 1290 CONVERT_ARG_CHECKED(JSArray, prototype, 0); |
1235 // This is necessary to enable fast checks for absence of elements | 1291 // This is necessary to enable fast checks for absence of elements |
1236 // on Array.prototype and below. | 1292 // on Array.prototype and below. |
1237 prototype->set_elements(Heap::empty_fixed_array()); | 1293 prototype->set_elements(Heap::empty_fixed_array()); |
1238 return Smi::FromInt(0); | 1294 return Smi::FromInt(0); |
1239 } | 1295 } |
1240 | 1296 |
(...skipping 8735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9976 } else { | 10032 } else { |
9977 // Handle last resort GC and make sure to allow future allocations | 10033 // Handle last resort GC and make sure to allow future allocations |
9978 // to grow the heap without causing GCs (if possible). | 10034 // to grow the heap without causing GCs (if possible). |
9979 Counters::gc_last_resort_from_js.Increment(); | 10035 Counters::gc_last_resort_from_js.Increment(); |
9980 Heap::CollectAllGarbage(false); | 10036 Heap::CollectAllGarbage(false); |
9981 } | 10037 } |
9982 } | 10038 } |
9983 | 10039 |
9984 | 10040 |
9985 } } // namespace v8::internal | 10041 } } // namespace v8::internal |
OLD | NEW |