Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2594 Handle<Object> result = RegExpImpl::Exec(regexp, | 2594 Handle<Object> result = RegExpImpl::Exec(regexp, |
| 2595 subject, | 2595 subject, |
| 2596 index, | 2596 index, |
| 2597 last_match_info); | 2597 last_match_info); |
| 2598 RETURN_IF_EMPTY_HANDLE(isolate, result); | 2598 RETURN_IF_EMPTY_HANDLE(isolate, result); |
| 2599 return *result; | 2599 return *result; |
| 2600 } | 2600 } |
| 2601 | 2601 |
| 2602 | 2602 |
| 2603 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_RegExpConstructResult) { | 2603 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_RegExpConstructResult) { |
| 2604 SealHandleScope shs(isolate); | 2604 HandleScope handle_scope(isolate); |
| 2605 ASSERT(args.length() == 3); | 2605 ASSERT(args.length() == 3); |
| 2606 CONVERT_SMI_ARG_CHECKED(elements_count, 0); | 2606 CONVERT_SMI_ARG_CHECKED(size, 0); |
| 2607 if (elements_count < 0 || | 2607 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); |
|
mvstanton
2014/04/07 14:28:49
So you don't bother with !Smi::IsValid(size) becau
Yang
2014/04/07 14:47:01
Yes.
| |
| 2608 elements_count > FixedArray::kMaxLength || | 2608 RUNTIME_ASSERT(args[1]->IsSmi()); |
| 2609 !Smi::IsValid(elements_count)) { | 2609 RUNTIME_ASSERT(args[2]->IsSmi()); |
|
mvstanton
2014/04/07 14:28:49
Do args[1] and args[2] actually need to be smis?
Yang
2014/04/07 14:47:01
You are right. They actually are not necessarily s
| |
| 2610 return isolate->ThrowIllegalOperation(); | 2610 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); |
| 2611 } | 2611 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); |
| 2612 Object* new_object; | 2612 Handle<JSObject> object = |
| 2613 { MaybeObject* maybe_new_object = | 2613 isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED, false); |
| 2614 isolate->heap()->AllocateFixedArray(elements_count); | 2614 Handle<JSArray> array = Handle<JSArray>::cast(object); |
| 2615 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; | 2615 array->set_elements(*elements); |
| 2616 } | 2616 array->set_length(Smi::FromInt(size)); |
| 2617 FixedArray* elements = FixedArray::cast(new_object); | |
| 2618 { MaybeObject* maybe_new_object = isolate->heap()->AllocateRaw( | |
| 2619 JSRegExpResult::kSize, NEW_SPACE, OLD_POINTER_SPACE); | |
| 2620 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; | |
| 2621 } | |
| 2622 { | |
| 2623 DisallowHeapAllocation no_gc; | |
| 2624 HandleScope scope(isolate); | |
| 2625 reinterpret_cast<HeapObject*>(new_object)-> | |
| 2626 set_map(isolate->native_context()->regexp_result_map()); | |
| 2627 } | |
| 2628 JSArray* array = JSArray::cast(new_object); | |
| 2629 array->set_properties(isolate->heap()->empty_fixed_array()); | |
| 2630 array->set_elements(elements); | |
| 2631 array->set_length(Smi::FromInt(elements_count)); | |
| 2632 // Write in-object properties after the length of the array. | 2617 // Write in-object properties after the length of the array. |
| 2633 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]); | 2618 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]); |
| 2634 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]); | 2619 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]); |
| 2635 return array; | 2620 return *array; |
| 2636 } | 2621 } |
| 2637 | 2622 |
| 2638 | 2623 |
| 2639 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { | 2624 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { |
| 2640 HandleScope scope(isolate); | 2625 HandleScope scope(isolate); |
| 2641 ASSERT(args.length() == 5); | 2626 ASSERT(args.length() == 5); |
| 2642 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); | 2627 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); |
| 2643 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 2628 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
| 2644 // If source is the empty string we set it to "(?:)" instead as | 2629 // If source is the empty string we set it to "(?:)" instead as |
| 2645 // suggested by ECMA-262, 5th, section 15.10.4.1. | 2630 // suggested by ECMA-262, 5th, section 15.10.4.1. |
| (...skipping 12615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15261 } | 15246 } |
| 15262 } | 15247 } |
| 15263 | 15248 |
| 15264 | 15249 |
| 15265 void Runtime::OutOfMemory() { | 15250 void Runtime::OutOfMemory() { |
| 15266 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15251 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
| 15267 UNREACHABLE(); | 15252 UNREACHABLE(); |
| 15268 } | 15253 } |
| 15269 | 15254 |
| 15270 } } // namespace v8::internal | 15255 } } // namespace v8::internal |
| OLD | NEW |