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() == 5); | 2551 DCHECK(args.length() == 6); |
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 |
2567 Map* map = regexp->map(); | 2570 Map* map = regexp->map(); |
2568 Object* constructor = map->constructor(); | 2571 Object* constructor = map->constructor(); |
2569 if (constructor->IsJSFunction() && | 2572 if (!FLAG_harmony_regexps && |
| 2573 constructor->IsJSFunction() && |
2570 JSFunction::cast(constructor)->initial_map() == map) { | 2574 JSFunction::cast(constructor)->initial_map() == map) { |
2571 // If we still have the original map, set in-object properties directly. | 2575 // If we still have the original map, set in-object properties directly. |
2572 regexp->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, *source); | 2576 regexp->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, *source); |
2573 // Both true and false are immovable immortal objects so no need for write | 2577 // Both true and false are immovable immortal objects so no need for write |
2574 // barrier. | 2578 // barrier. |
2575 regexp->InObjectPropertyAtPut( | 2579 regexp->InObjectPropertyAtPut( |
2576 JSRegExp::kGlobalFieldIndex, *global, SKIP_WRITE_BARRIER); | 2580 JSRegExp::kGlobalFieldIndex, *global, SKIP_WRITE_BARRIER); |
2577 regexp->InObjectPropertyAtPut( | 2581 regexp->InObjectPropertyAtPut( |
2578 JSRegExp::kIgnoreCaseFieldIndex, *ignoreCase, SKIP_WRITE_BARRIER); | 2582 JSRegExp::kIgnoreCaseFieldIndex, *ignoreCase, SKIP_WRITE_BARRIER); |
2579 regexp->InObjectPropertyAtPut( | 2583 regexp->InObjectPropertyAtPut( |
2580 JSRegExp::kMultilineFieldIndex, *multiline, SKIP_WRITE_BARRIER); | 2584 JSRegExp::kMultilineFieldIndex, *multiline, SKIP_WRITE_BARRIER); |
2581 regexp->InObjectPropertyAtPut( | 2585 regexp->InObjectPropertyAtPut( |
2582 JSRegExp::kLastIndexFieldIndex, Smi::FromInt(0), SKIP_WRITE_BARRIER); | 2586 JSRegExp::kLastIndexFieldIndex, Smi::FromInt(0), SKIP_WRITE_BARRIER); |
2583 return *regexp; | 2587 return *regexp; |
2584 } | 2588 } |
2585 | 2589 |
2586 // Map has changed, so use generic, but slower, method. | 2590 // Map has changed, so use generic, but slower, method. We also end here if |
| 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. |
2587 PropertyAttributes final = | 2595 PropertyAttributes final = |
2588 static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE); | 2596 static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE); |
2589 PropertyAttributes writable = | 2597 PropertyAttributes writable = |
2590 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); | 2598 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
2591 Handle<Object> zero(Smi::FromInt(0), isolate); | 2599 Handle<Object> zero(Smi::FromInt(0), isolate); |
2592 Factory* factory = isolate->factory(); | 2600 Factory* factory = isolate->factory(); |
2593 JSObject::SetOwnPropertyIgnoreAttributes( | 2601 JSObject::SetOwnPropertyIgnoreAttributes( |
2594 regexp, factory->source_string(), source, final).Check(); | 2602 regexp, factory->source_string(), source, final).Check(); |
2595 JSObject::SetOwnPropertyIgnoreAttributes( | 2603 JSObject::SetOwnPropertyIgnoreAttributes( |
2596 regexp, factory->global_string(), global, final).Check(); | 2604 regexp, factory->global_string(), global, final).Check(); |
2597 JSObject::SetOwnPropertyIgnoreAttributes( | 2605 JSObject::SetOwnPropertyIgnoreAttributes( |
2598 regexp, factory->ignore_case_string(), ignoreCase, final).Check(); | 2606 regexp, factory->ignore_case_string(), ignoreCase, final).Check(); |
2599 JSObject::SetOwnPropertyIgnoreAttributes( | 2607 JSObject::SetOwnPropertyIgnoreAttributes( |
2600 regexp, factory->multiline_string(), multiline, final).Check(); | 2608 regexp, factory->multiline_string(), multiline, final).Check(); |
| 2609 if (FLAG_harmony_regexps) { |
| 2610 JSObject::SetOwnPropertyIgnoreAttributes( |
| 2611 regexp, factory->sticky_string(), sticky, final).Check(); |
| 2612 } |
2601 JSObject::SetOwnPropertyIgnoreAttributes( | 2613 JSObject::SetOwnPropertyIgnoreAttributes( |
2602 regexp, factory->last_index_string(), zero, writable).Check(); | 2614 regexp, factory->last_index_string(), zero, writable).Check(); |
2603 return *regexp; | 2615 return *regexp; |
2604 } | 2616 } |
2605 | 2617 |
2606 | 2618 |
2607 RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) { | 2619 RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) { |
2608 HandleScope scope(isolate); | 2620 HandleScope scope(isolate); |
2609 DCHECK(args.length() == 1); | 2621 DCHECK(args.length() == 1); |
2610 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); | 2622 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); |
(...skipping 13070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15681 } | 15693 } |
15682 return NULL; | 15694 return NULL; |
15683 } | 15695 } |
15684 | 15696 |
15685 | 15697 |
15686 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15698 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15687 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15699 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15688 } | 15700 } |
15689 | 15701 |
15690 } } // namespace v8::internal | 15702 } } // namespace v8::internal |
OLD | NEW |