OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 "src/factory.h" | 5 #include "src/factory.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
600 return result; | 600 return result; |
601 } | 601 } |
602 | 602 |
603 | 603 |
604 Handle<String> Factory::NewProperSubString(Handle<String> str, | 604 Handle<String> Factory::NewProperSubString(Handle<String> str, |
605 int begin, | 605 int begin, |
606 int end) { | 606 int end) { |
607 #if VERIFY_HEAP | 607 #if VERIFY_HEAP |
608 if (FLAG_verify_heap) str->StringVerify(); | 608 if (FLAG_verify_heap) str->StringVerify(); |
609 #endif | 609 #endif |
610 DCHECK(begin > 0 || end < str->length()); | 610 DCHECK(begin > 0 || end <= str->length()); |
Benedikt Meurer
2016/09/19 04:05:18
This still looks wrong to me. Please undo this cha
caitp
2016/09/19 16:03:05
Done.
| |
611 | 611 |
612 str = String::Flatten(str); | 612 str = String::Flatten(str); |
613 | 613 |
614 int length = end - begin; | 614 int length = end - begin; |
615 if (length <= 0) return empty_string(); | 615 if (length <= 0) return empty_string(); |
616 if (length == 1) { | 616 if (length == 1) { |
617 return LookupSingleCharacterStringFromCode(str->Get(begin)); | 617 return LookupSingleCharacterStringFromCode(str->Get(begin)); |
618 } | 618 } |
619 if (length == 2) { | 619 if (length == 2) { |
620 // Optimization for 2-byte strings often used as keys in a decompression | 620 // Optimization for 2-byte strings often used as keys in a decompression |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
727 Handle<Map> map = native_source_string_map(); | 727 Handle<Map> map = native_source_string_map(); |
728 Handle<ExternalOneByteString> external_string = | 728 Handle<ExternalOneByteString> external_string = |
729 New<ExternalOneByteString>(map, OLD_SPACE); | 729 New<ExternalOneByteString>(map, OLD_SPACE); |
730 external_string->set_length(static_cast<int>(length)); | 730 external_string->set_length(static_cast<int>(length)); |
731 external_string->set_hash_field(String::kEmptyHashField); | 731 external_string->set_hash_field(String::kEmptyHashField); |
732 external_string->set_resource(resource); | 732 external_string->set_resource(resource); |
733 | 733 |
734 return external_string; | 734 return external_string; |
735 } | 735 } |
736 | 736 |
737 Handle<JSStringIterator> Factory::NewJSStringIterator(Handle<String> string) { | |
738 Handle<Map> map(isolate()->native_context()->string_iterator_map()); | |
Benedikt Meurer
2016/09/19 04:05:18
Nit: Handle<Map> map(isolate()->native_context()->
caitp
2016/09/19 16:03:05
Done.
| |
739 Handle<String> flat_string = String::Flatten(string); | |
740 Handle<JSStringIterator> iterator = | |
741 Handle<JSStringIterator>::cast(NewJSObjectFromMap(map)); | |
742 iterator->set_string(*flat_string); | |
743 iterator->set_index(0); | |
744 | |
745 return iterator; | |
746 } | |
737 | 747 |
738 Handle<Symbol> Factory::NewSymbol() { | 748 Handle<Symbol> Factory::NewSymbol() { |
739 CALL_HEAP_FUNCTION( | 749 CALL_HEAP_FUNCTION( |
740 isolate(), | 750 isolate(), |
741 isolate()->heap()->AllocateSymbol(), | 751 isolate()->heap()->AllocateSymbol(), |
742 Symbol); | 752 Symbol); |
743 } | 753 } |
744 | 754 |
745 | 755 |
746 Handle<Symbol> Factory::NewPrivateSymbol() { | 756 Handle<Symbol> Factory::NewPrivateSymbol() { |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1725 | 1735 |
1726 Handle<JSDataView> Factory::NewJSDataView() { | 1736 Handle<JSDataView> Factory::NewJSDataView() { |
1727 Handle<JSFunction> data_view_fun( | 1737 Handle<JSFunction> data_view_fun( |
1728 isolate()->native_context()->data_view_fun()); | 1738 isolate()->native_context()->data_view_fun()); |
1729 CALL_HEAP_FUNCTION( | 1739 CALL_HEAP_FUNCTION( |
1730 isolate(), | 1740 isolate(), |
1731 isolate()->heap()->AllocateJSObject(*data_view_fun), | 1741 isolate()->heap()->AllocateJSObject(*data_view_fun), |
1732 JSDataView); | 1742 JSDataView); |
1733 } | 1743 } |
1734 | 1744 |
1745 Handle<JSIteratorResult> Factory::NewJSIteratorResult(Handle<Object> value, | |
1746 bool done) { | |
1747 Handle<Map> map(isolate()->native_context()->iterator_result_map()); | |
1748 Handle<JSIteratorResult> js_iter_result = | |
1749 Handle<JSIteratorResult>::cast(NewJSObjectFromMap(map)); | |
1750 js_iter_result->set_value(*value); | |
1751 js_iter_result->set_done(*ToBoolean(done)); | |
1752 return js_iter_result; | |
1753 } | |
1735 | 1754 |
1736 Handle<JSMap> Factory::NewJSMap() { | 1755 Handle<JSMap> Factory::NewJSMap() { |
1737 Handle<Map> map(isolate()->native_context()->js_map_map()); | 1756 Handle<Map> map(isolate()->native_context()->js_map_map()); |
1738 Handle<JSMap> js_map = Handle<JSMap>::cast(NewJSObjectFromMap(map)); | 1757 Handle<JSMap> js_map = Handle<JSMap>::cast(NewJSObjectFromMap(map)); |
1739 JSMap::Initialize(js_map, isolate()); | 1758 JSMap::Initialize(js_map, isolate()); |
1740 return js_map; | 1759 return js_map; |
1741 } | 1760 } |
1742 | 1761 |
1743 | 1762 |
1744 Handle<JSSet> Factory::NewJSSet() { | 1763 Handle<JSSet> Factory::NewJSSet() { |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2531 Handle<AccessorInfo> prototype = | 2550 Handle<AccessorInfo> prototype = |
2532 Accessors::FunctionPrototypeInfo(isolate(), attribs); | 2551 Accessors::FunctionPrototypeInfo(isolate(), attribs); |
2533 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), | 2552 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
2534 prototype, attribs); | 2553 prototype, attribs); |
2535 map->AppendDescriptor(&d); | 2554 map->AppendDescriptor(&d); |
2536 } | 2555 } |
2537 } | 2556 } |
2538 | 2557 |
2539 } // namespace internal | 2558 } // namespace internal |
2540 } // namespace v8 | 2559 } // namespace v8 |
OLD | NEW |