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 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1253 | 1253 |
1254 | 1254 |
1255 RUNTIME_FUNCTION(Runtime_TypedArrayMaxSizeInHeap) { | 1255 RUNTIME_FUNCTION(Runtime_TypedArrayMaxSizeInHeap) { |
1256 DCHECK(args.length() == 0); | 1256 DCHECK(args.length() == 0); |
1257 DCHECK_OBJECT_SIZE( | 1257 DCHECK_OBJECT_SIZE( |
1258 FLAG_typed_array_max_size_in_heap + FixedTypedArrayBase::kDataOffset); | 1258 FLAG_typed_array_max_size_in_heap + FixedTypedArrayBase::kDataOffset); |
1259 return Smi::FromInt(FLAG_typed_array_max_size_in_heap); | 1259 return Smi::FromInt(FLAG_typed_array_max_size_in_heap); |
1260 } | 1260 } |
1261 | 1261 |
1262 | 1262 |
1263 RUNTIME_FUNCTION(Runtime_HarmonyRegExps) { | |
1264 DCHECK(args.length() == 0); | |
1265 if (FLAG_harmony_regexps) | |
Yang
2014/09/15 09:23:16
You could also use isolate->heap()->ToBoolean(FLAG
Erik Corry
2014/09/16 17:49:40
This is gone now.
| |
1266 return isolate->heap()->true_value(); | |
1267 return isolate->heap()->false_value(); | |
1268 } | |
1269 | |
1270 | |
1263 RUNTIME_FUNCTION(Runtime_DataViewInitialize) { | 1271 RUNTIME_FUNCTION(Runtime_DataViewInitialize) { |
1264 HandleScope scope(isolate); | 1272 HandleScope scope(isolate); |
1265 DCHECK(args.length() == 4); | 1273 DCHECK(args.length() == 4); |
1266 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | 1274 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); |
1267 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); | 1275 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); |
1268 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_offset, 2); | 1276 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_offset, 2); |
1269 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_length, 3); | 1277 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_length, 3); |
1270 | 1278 |
1271 DCHECK(holder->GetInternalFieldCount() == | 1279 DCHECK(holder->GetInternalFieldCount() == |
1272 v8::ArrayBufferView::kInternalFieldCount); | 1280 v8::ArrayBufferView::kInternalFieldCount); |
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2541 array->set_length(Smi::FromInt(size)); | 2549 array->set_length(Smi::FromInt(size)); |
2542 // Write in-object properties after the length of the array. | 2550 // Write in-object properties after the length of the array. |
2543 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, *index); | 2551 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, *index); |
2544 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, *input); | 2552 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, *input); |
2545 return *array; | 2553 return *array; |
2546 } | 2554 } |
2547 | 2555 |
2548 | 2556 |
2549 RUNTIME_FUNCTION(Runtime_RegExpInitializeObject) { | 2557 RUNTIME_FUNCTION(Runtime_RegExpInitializeObject) { |
2550 HandleScope scope(isolate); | 2558 HandleScope scope(isolate); |
2551 DCHECK(args.length() == 5); | 2559 DCHECK(args.length() == 6); |
2552 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); | 2560 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); |
2553 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 2561 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
2554 // If source is the empty string we set it to "(?:)" instead as | 2562 // If source is the empty string we set it to "(?:)" instead as |
2555 // suggested by ECMA-262, 5th, section 15.10.4.1. | 2563 // suggested by ECMA-262, 5th, section 15.10.4.1. |
2556 if (source->length() == 0) source = isolate->factory()->query_colon_string(); | 2564 if (source->length() == 0) source = isolate->factory()->query_colon_string(); |
2557 | 2565 |
2558 CONVERT_ARG_HANDLE_CHECKED(Object, global, 2); | 2566 CONVERT_ARG_HANDLE_CHECKED(Object, global, 2); |
2559 if (!global->IsTrue()) global = isolate->factory()->false_value(); | 2567 if (!global->IsTrue()) global = isolate->factory()->false_value(); |
2560 | 2568 |
2561 CONVERT_ARG_HANDLE_CHECKED(Object, ignoreCase, 3); | 2569 CONVERT_ARG_HANDLE_CHECKED(Object, ignoreCase, 3); |
2562 if (!ignoreCase->IsTrue()) ignoreCase = isolate->factory()->false_value(); | 2570 if (!ignoreCase->IsTrue()) ignoreCase = isolate->factory()->false_value(); |
2563 | 2571 |
2564 CONVERT_ARG_HANDLE_CHECKED(Object, multiline, 4); | 2572 CONVERT_ARG_HANDLE_CHECKED(Object, multiline, 4); |
2565 if (!multiline->IsTrue()) multiline = isolate->factory()->false_value(); | 2573 if (!multiline->IsTrue()) multiline = isolate->factory()->false_value(); |
2566 | 2574 |
2575 CONVERT_ARG_HANDLE_CHECKED(Object, sticky, 5); | |
2576 if (!sticky->IsTrue()) sticky = isolate->factory()->false_value(); | |
2577 | |
2567 Map* map = regexp->map(); | 2578 Map* map = regexp->map(); |
2568 Object* constructor = map->constructor(); | 2579 Object* constructor = map->constructor(); |
2569 if (constructor->IsJSFunction() && | 2580 if (!FLAG_harmony_regexps && |
2581 constructor->IsJSFunction() && | |
2570 JSFunction::cast(constructor)->initial_map() == map) { | 2582 JSFunction::cast(constructor)->initial_map() == map) { |
2571 // If we still have the original map, set in-object properties directly. | 2583 // If we still have the original map, set in-object properties directly. |
2572 regexp->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, *source); | 2584 regexp->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, *source); |
2573 // Both true and false are immovable immortal objects so no need for write | 2585 // Both true and false are immovable immortal objects so no need for write |
2574 // barrier. | 2586 // barrier. |
2575 regexp->InObjectPropertyAtPut( | 2587 regexp->InObjectPropertyAtPut( |
2576 JSRegExp::kGlobalFieldIndex, *global, SKIP_WRITE_BARRIER); | 2588 JSRegExp::kGlobalFieldIndex, *global, SKIP_WRITE_BARRIER); |
2577 regexp->InObjectPropertyAtPut( | 2589 regexp->InObjectPropertyAtPut( |
2578 JSRegExp::kIgnoreCaseFieldIndex, *ignoreCase, SKIP_WRITE_BARRIER); | 2590 JSRegExp::kIgnoreCaseFieldIndex, *ignoreCase, SKIP_WRITE_BARRIER); |
2579 regexp->InObjectPropertyAtPut( | 2591 regexp->InObjectPropertyAtPut( |
2580 JSRegExp::kMultilineFieldIndex, *multiline, SKIP_WRITE_BARRIER); | 2592 JSRegExp::kMultilineFieldIndex, *multiline, SKIP_WRITE_BARRIER); |
2581 regexp->InObjectPropertyAtPut( | 2593 regexp->InObjectPropertyAtPut( |
2582 JSRegExp::kLastIndexFieldIndex, Smi::FromInt(0), SKIP_WRITE_BARRIER); | 2594 JSRegExp::kLastIndexFieldIndex, Smi::FromInt(0), SKIP_WRITE_BARRIER); |
2583 return *regexp; | 2595 return *regexp; |
2584 } | 2596 } |
2585 | 2597 |
2586 // Map has changed, so use generic, but slower, method. | 2598 // Map has changed, so use generic, but slower, method. We also end here if |
2599 // the --harmony-regexp flag is set, because the initial map does not have | |
2600 // space for the 'sticky' flag, since is from the snapshot, but must work both | |
mathias
2014/09/15 15:19:10
Typo: “since is”
Erik Corry
2014/09/16 17:49:40
Done.
| |
2601 // with and without --harmony-regexp. When sticky comes out from under the | |
2602 // flag, we will be able to use the fast initial map. | |
2587 PropertyAttributes final = | 2603 PropertyAttributes final = |
2588 static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE); | 2604 static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE); |
2589 PropertyAttributes writable = | 2605 PropertyAttributes writable = |
2590 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); | 2606 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
2591 Handle<Object> zero(Smi::FromInt(0), isolate); | 2607 Handle<Object> zero(Smi::FromInt(0), isolate); |
2592 Factory* factory = isolate->factory(); | 2608 Factory* factory = isolate->factory(); |
2593 JSObject::SetOwnPropertyIgnoreAttributes( | 2609 JSObject::SetOwnPropertyIgnoreAttributes( |
2594 regexp, factory->source_string(), source, final).Check(); | 2610 regexp, factory->source_string(), source, final).Check(); |
2595 JSObject::SetOwnPropertyIgnoreAttributes( | 2611 JSObject::SetOwnPropertyIgnoreAttributes( |
2596 regexp, factory->global_string(), global, final).Check(); | 2612 regexp, factory->global_string(), global, final).Check(); |
2597 JSObject::SetOwnPropertyIgnoreAttributes( | 2613 JSObject::SetOwnPropertyIgnoreAttributes( |
2598 regexp, factory->ignore_case_string(), ignoreCase, final).Check(); | 2614 regexp, factory->ignore_case_string(), ignoreCase, final).Check(); |
2599 JSObject::SetOwnPropertyIgnoreAttributes( | 2615 JSObject::SetOwnPropertyIgnoreAttributes( |
2600 regexp, factory->multiline_string(), multiline, final).Check(); | 2616 regexp, factory->multiline_string(), multiline, final).Check(); |
2601 JSObject::SetOwnPropertyIgnoreAttributes( | 2617 JSObject::SetOwnPropertyIgnoreAttributes( |
2618 regexp, factory->sticky_string(), sticky, final).Check(); | |
2619 JSObject::SetOwnPropertyIgnoreAttributes( | |
2602 regexp, factory->last_index_string(), zero, writable).Check(); | 2620 regexp, factory->last_index_string(), zero, writable).Check(); |
2603 return *regexp; | 2621 return *regexp; |
2604 } | 2622 } |
2605 | 2623 |
2606 | 2624 |
2607 RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) { | 2625 RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) { |
2608 HandleScope scope(isolate); | 2626 HandleScope scope(isolate); |
2609 DCHECK(args.length() == 1); | 2627 DCHECK(args.length() == 1); |
2610 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); | 2628 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); |
2611 Object* length = prototype->length(); | 2629 Object* length = prototype->length(); |
(...skipping 13066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15678 } | 15696 } |
15679 return NULL; | 15697 return NULL; |
15680 } | 15698 } |
15681 | 15699 |
15682 | 15700 |
15683 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15701 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15684 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15702 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15685 } | 15703 } |
15686 | 15704 |
15687 } } // namespace v8::internal | 15705 } } // namespace v8::internal |
OLD | NEW |