OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 2530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2541 array->set_length(Smi::FromInt(size)); | 2541 array->set_length(Smi::FromInt(size)); |
2542 // Write in-object properties after the length of the array. | 2542 // Write in-object properties after the length of the array. |
2543 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, *index); | 2543 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, *index); |
2544 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, *input); | 2544 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, *input); |
2545 return *array; | 2545 return *array; |
2546 } | 2546 } |
2547 | 2547 |
2548 | 2548 |
2549 RUNTIME_FUNCTION(Runtime_RegExpInitializeObject) { | 2549 RUNTIME_FUNCTION(Runtime_RegExpInitializeObject) { |
2550 HandleScope scope(isolate); | 2550 HandleScope scope(isolate); |
2551 DCHECK(args.length() == 6); | 2551 DCHECK(args.length() == 5); |
2552 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); | 2552 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); |
2553 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 2553 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
2554 // If source is the empty string we set it to "(?:)" instead as | 2554 // If source is the empty string we set it to "(?:)" instead as |
2555 // suggested by ECMA-262, 5th, section 15.10.4.1. | 2555 // suggested by ECMA-262, 5th, section 15.10.4.1. |
2556 if (source->length() == 0) source = isolate->factory()->query_colon_string(); | 2556 if (source->length() == 0) source = isolate->factory()->query_colon_string(); |
2557 | 2557 |
2558 CONVERT_ARG_HANDLE_CHECKED(Object, global, 2); | 2558 CONVERT_ARG_HANDLE_CHECKED(Object, global, 2); |
2559 if (!global->IsTrue()) global = isolate->factory()->false_value(); | 2559 if (!global->IsTrue()) global = isolate->factory()->false_value(); |
2560 | 2560 |
2561 CONVERT_ARG_HANDLE_CHECKED(Object, ignoreCase, 3); | 2561 CONVERT_ARG_HANDLE_CHECKED(Object, ignoreCase, 3); |
2562 if (!ignoreCase->IsTrue()) ignoreCase = isolate->factory()->false_value(); | 2562 if (!ignoreCase->IsTrue()) ignoreCase = isolate->factory()->false_value(); |
2563 | 2563 |
2564 CONVERT_ARG_HANDLE_CHECKED(Object, multiline, 4); | 2564 CONVERT_ARG_HANDLE_CHECKED(Object, multiline, 4); |
2565 if (!multiline->IsTrue()) multiline = isolate->factory()->false_value(); | 2565 if (!multiline->IsTrue()) multiline = isolate->factory()->false_value(); |
2566 | 2566 |
2567 CONVERT_ARG_HANDLE_CHECKED(Object, sticky, 5); | |
2568 if (!sticky->IsTrue()) sticky = isolate->factory()->false_value(); | |
2569 | |
2570 Map* map = regexp->map(); | 2567 Map* map = regexp->map(); |
2571 Object* constructor = map->constructor(); | 2568 Object* constructor = map->constructor(); |
2572 if (!FLAG_harmony_regexps && | 2569 if (constructor->IsJSFunction() && |
2573 constructor->IsJSFunction() && | |
2574 JSFunction::cast(constructor)->initial_map() == map) { | 2570 JSFunction::cast(constructor)->initial_map() == map) { |
2575 // If we still have the original map, set in-object properties directly. | 2571 // If we still have the original map, set in-object properties directly. |
2576 regexp->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, *source); | 2572 regexp->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, *source); |
2577 // Both true and false are immovable immortal objects so no need for write | 2573 // Both true and false are immovable immortal objects so no need for write |
2578 // barrier. | 2574 // barrier. |
2579 regexp->InObjectPropertyAtPut( | 2575 regexp->InObjectPropertyAtPut( |
2580 JSRegExp::kGlobalFieldIndex, *global, SKIP_WRITE_BARRIER); | 2576 JSRegExp::kGlobalFieldIndex, *global, SKIP_WRITE_BARRIER); |
2581 regexp->InObjectPropertyAtPut( | 2577 regexp->InObjectPropertyAtPut( |
2582 JSRegExp::kIgnoreCaseFieldIndex, *ignoreCase, SKIP_WRITE_BARRIER); | 2578 JSRegExp::kIgnoreCaseFieldIndex, *ignoreCase, SKIP_WRITE_BARRIER); |
2583 regexp->InObjectPropertyAtPut( | 2579 regexp->InObjectPropertyAtPut( |
2584 JSRegExp::kMultilineFieldIndex, *multiline, SKIP_WRITE_BARRIER); | 2580 JSRegExp::kMultilineFieldIndex, *multiline, SKIP_WRITE_BARRIER); |
2585 regexp->InObjectPropertyAtPut( | 2581 regexp->InObjectPropertyAtPut( |
2586 JSRegExp::kLastIndexFieldIndex, Smi::FromInt(0), SKIP_WRITE_BARRIER); | 2582 JSRegExp::kLastIndexFieldIndex, Smi::FromInt(0), SKIP_WRITE_BARRIER); |
2587 return *regexp; | 2583 return *regexp; |
2588 } | 2584 } |
2589 | 2585 |
2590 // Map has changed, so use generic, but slower, method. We also end here if | 2586 // Map has changed, so use generic, but slower, method. |
2591 // the --harmony-regexp flag is set, because the initial map does not have | |
2592 // space for the 'sticky' flag, since it is from the snapshot, but must work | |
2593 // both with and without --harmony-regexp. When sticky comes out from under | |
2594 // the flag, we will be able to use the fast initial map. | |
2595 PropertyAttributes final = | 2587 PropertyAttributes final = |
2596 static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE); | 2588 static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE); |
2597 PropertyAttributes writable = | 2589 PropertyAttributes writable = |
2598 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); | 2590 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
2599 Handle<Object> zero(Smi::FromInt(0), isolate); | 2591 Handle<Object> zero(Smi::FromInt(0), isolate); |
2600 Factory* factory = isolate->factory(); | 2592 Factory* factory = isolate->factory(); |
2601 JSObject::SetOwnPropertyIgnoreAttributes( | 2593 JSObject::SetOwnPropertyIgnoreAttributes( |
2602 regexp, factory->source_string(), source, final).Check(); | 2594 regexp, factory->source_string(), source, final).Check(); |
2603 JSObject::SetOwnPropertyIgnoreAttributes( | 2595 JSObject::SetOwnPropertyIgnoreAttributes( |
2604 regexp, factory->global_string(), global, final).Check(); | 2596 regexp, factory->global_string(), global, final).Check(); |
2605 JSObject::SetOwnPropertyIgnoreAttributes( | 2597 JSObject::SetOwnPropertyIgnoreAttributes( |
2606 regexp, factory->ignore_case_string(), ignoreCase, final).Check(); | 2598 regexp, factory->ignore_case_string(), ignoreCase, final).Check(); |
2607 JSObject::SetOwnPropertyIgnoreAttributes( | 2599 JSObject::SetOwnPropertyIgnoreAttributes( |
2608 regexp, factory->multiline_string(), multiline, final).Check(); | 2600 regexp, factory->multiline_string(), multiline, final).Check(); |
2609 if (FLAG_harmony_regexps) { | |
2610 JSObject::SetOwnPropertyIgnoreAttributes( | |
2611 regexp, factory->sticky_string(), sticky, final).Check(); | |
2612 } | |
2613 JSObject::SetOwnPropertyIgnoreAttributes( | 2601 JSObject::SetOwnPropertyIgnoreAttributes( |
2614 regexp, factory->last_index_string(), zero, writable).Check(); | 2602 regexp, factory->last_index_string(), zero, writable).Check(); |
2615 return *regexp; | 2603 return *regexp; |
2616 } | 2604 } |
2617 | 2605 |
2618 | 2606 |
2619 RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) { | 2607 RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) { |
2620 HandleScope scope(isolate); | 2608 HandleScope scope(isolate); |
2621 DCHECK(args.length() == 1); | 2609 DCHECK(args.length() == 1); |
2622 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); | 2610 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); |
(...skipping 13137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15760 } | 15748 } |
15761 return NULL; | 15749 return NULL; |
15762 } | 15750 } |
15763 | 15751 |
15764 | 15752 |
15765 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15753 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15766 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15754 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15767 } | 15755 } |
15768 | 15756 |
15769 } } // namespace v8::internal | 15757 } } // namespace v8::internal |
OLD | NEW |