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

Side by Side Diff: src/runtime.cc

Issue 1645001: Native construction of RegExp result objects, with in-object index and input. (Closed)
Patch Set: Created 10 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
OLDNEW
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
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_RegExpConstructResult(Arguments args) {
1232 ASSERT(args.length() == 3);
1233 CONVERT_SMI_CHECKED(elements_count, args[0]);
1234 if (elements_count > JSArray::kMaxFastElementsLength) {
1235 return Top::ThrowIllegalOperation();
1236 }
1237 Object* new_object = Heap::AllocateFixedArrayWithHoles(elements_count);
1238 if (new_object->IsFailure()) return new_object;
1239 FixedArray* elements = FixedArray::cast(new_object);
1240 new_object = Heap::AllocateRaw(JSArray::kRegExpResultSize,
1241 NEW_SPACE,
1242 OLD_POINTER_SPACE);
1243 if (new_object->IsFailure()) return new_object;
1244 {
1245 AssertNoAllocation no_gc;
1246 HandleScope scope;
1247 reinterpret_cast<HeapObject*>(new_object)->
1248 set_map(Top::global_context()->regexp_result_map());
1249 }
1250 JSArray* array = JSArray::cast(new_object);
1251 array->set_properties(Heap::empty_fixed_array());
1252 array->set_elements(elements);
1253 array->set_length(Smi::FromInt(elements_count));
1254 // Write in-object properties after the length of the array.
Søren Thygesen Gjesse 2010/04/13 07:22:29 Move the constants to JSRegExpResult (see comment
Lasse Reichstein 2010/04/13 09:50:56 Done.
1255 array->InObjectPropertyAtPut(JSArray::kIndexIndex, args[1]);
1256 array->InObjectPropertyAtPut(JSArray::kInputIndex, args[2]);
1257 return array;
1258 }
1259
1260
1231 static Object* Runtime_RegExpInitializeObject(Arguments args) { 1261 static Object* Runtime_RegExpInitializeObject(Arguments args) {
1232 AssertNoAllocation no_alloc; 1262 AssertNoAllocation no_alloc;
1233 ASSERT(args.length() == 5); 1263 ASSERT(args.length() == 5);
1234 CONVERT_CHECKED(JSRegExp, regexp, args[0]); 1264 CONVERT_CHECKED(JSRegExp, regexp, args[0]);
1235 CONVERT_CHECKED(String, source, args[1]); 1265 CONVERT_CHECKED(String, source, args[1]);
1236 1266
1237 Object* global = args[2]; 1267 Object* global = args[2];
1238 if (!global->IsTrue()) global = Heap::false_value(); 1268 if (!global->IsTrue()) global = Heap::false_value();
1239 1269
1240 Object* ignoreCase = args[3]; 1270 Object* ignoreCase = args[3];
(...skipping 8827 matching lines...) Expand 10 before | Expand all | Expand 10 after
10068 } else { 10098 } else {
10069 // Handle last resort GC and make sure to allow future allocations 10099 // Handle last resort GC and make sure to allow future allocations
10070 // to grow the heap without causing GCs (if possible). 10100 // to grow the heap without causing GCs (if possible).
10071 Counters::gc_last_resort_from_js.Increment(); 10101 Counters::gc_last_resort_from_js.Increment();
10072 Heap::CollectAllGarbage(false); 10102 Heap::CollectAllGarbage(false);
10073 } 10103 }
10074 } 10104 }
10075 10105
10076 10106
10077 } } // namespace v8::internal 10107 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698