| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 | 71 |
| 72 Handle<StringDictionary> Factory::NewStringDictionary(int at_least_space_for) { | 72 Handle<StringDictionary> Factory::NewStringDictionary(int at_least_space_for) { |
| 73 ASSERT(0 <= at_least_space_for); | 73 ASSERT(0 <= at_least_space_for); |
| 74 CALL_HEAP_FUNCTION(isolate(), | 74 CALL_HEAP_FUNCTION(isolate(), |
| 75 StringDictionary::Allocate(at_least_space_for), | 75 StringDictionary::Allocate(at_least_space_for), |
| 76 StringDictionary); | 76 StringDictionary); |
| 77 } | 77 } |
| 78 | 78 |
| 79 | 79 |
| 80 Handle<NumberDictionary> Factory::NewNumberDictionary(int at_least_space_for) { | 80 Handle<SeededNumberDictionary> Factory::NewSeededNumberDictionary( |
| 81 int at_least_space_for) { |
| 81 ASSERT(0 <= at_least_space_for); | 82 ASSERT(0 <= at_least_space_for); |
| 82 CALL_HEAP_FUNCTION(isolate(), | 83 CALL_HEAP_FUNCTION(isolate(), |
| 83 NumberDictionary::Allocate(at_least_space_for), | 84 SeededNumberDictionary::Allocate(at_least_space_for), |
| 84 NumberDictionary); | 85 SeededNumberDictionary); |
| 86 } |
| 87 |
| 88 |
| 89 Handle<UnseededNumberDictionary> Factory::NewUnseededNumberDictionary( |
| 90 int at_least_space_for) { |
| 91 ASSERT(0 <= at_least_space_for); |
| 92 CALL_HEAP_FUNCTION(isolate(), |
| 93 UnseededNumberDictionary::Allocate(at_least_space_for), |
| 94 UnseededNumberDictionary); |
| 85 } | 95 } |
| 86 | 96 |
| 87 | 97 |
| 88 Handle<ObjectHashSet> Factory::NewObjectHashSet(int at_least_space_for) { | 98 Handle<ObjectHashSet> Factory::NewObjectHashSet(int at_least_space_for) { |
| 89 ASSERT(0 <= at_least_space_for); | 99 ASSERT(0 <= at_least_space_for); |
| 90 CALL_HEAP_FUNCTION(isolate(), | 100 CALL_HEAP_FUNCTION(isolate(), |
| 91 ObjectHashSet::Allocate(at_least_space_for), | 101 ObjectHashSet::Allocate(at_least_space_for), |
| 92 ObjectHashSet); | 102 ObjectHashSet); |
| 93 } | 103 } |
| 94 | 104 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 124 int deopt_entry_count, | 134 int deopt_entry_count, |
| 125 PretenureFlag pretenure) { | 135 PretenureFlag pretenure) { |
| 126 ASSERT(deopt_entry_count > 0); | 136 ASSERT(deopt_entry_count > 0); |
| 127 CALL_HEAP_FUNCTION(isolate(), | 137 CALL_HEAP_FUNCTION(isolate(), |
| 128 DeoptimizationOutputData::Allocate(deopt_entry_count, | 138 DeoptimizationOutputData::Allocate(deopt_entry_count, |
| 129 pretenure), | 139 pretenure), |
| 130 DeoptimizationOutputData); | 140 DeoptimizationOutputData); |
| 131 } | 141 } |
| 132 | 142 |
| 133 | 143 |
| 144 Handle<AccessorPair> Factory::NewAccessorPair() { |
| 145 CALL_HEAP_FUNCTION(isolate(), |
| 146 isolate()->heap()->AllocateAccessorPair(), |
| 147 AccessorPair); |
| 148 } |
| 149 |
| 150 |
| 134 // Symbols are created in the old generation (data space). | 151 // Symbols are created in the old generation (data space). |
| 135 Handle<String> Factory::LookupSymbol(Vector<const char> string) { | 152 Handle<String> Factory::LookupSymbol(Vector<const char> string) { |
| 136 CALL_HEAP_FUNCTION(isolate(), | 153 CALL_HEAP_FUNCTION(isolate(), |
| 137 isolate()->heap()->LookupSymbol(string), | 154 isolate()->heap()->LookupSymbol(string), |
| 138 String); | 155 String); |
| 139 } | 156 } |
| 140 | 157 |
| 141 // Symbols are created in the old generation (data space). | 158 // Symbols are created in the old generation (data space). |
| 142 Handle<String> Factory::LookupSymbol(Handle<String> string) { | 159 Handle<String> Factory::LookupSymbol(Handle<String> string) { |
| 143 CALL_HEAP_FUNCTION(isolate(), | 160 CALL_HEAP_FUNCTION(isolate(), |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 708 |
| 692 | 709 |
| 693 Handle<JSFunction> Factory::NewFunction(Handle<String> name, | 710 Handle<JSFunction> Factory::NewFunction(Handle<String> name, |
| 694 InstanceType type, | 711 InstanceType type, |
| 695 int instance_size, | 712 int instance_size, |
| 696 Handle<Code> code, | 713 Handle<Code> code, |
| 697 bool force_initial_map) { | 714 bool force_initial_map) { |
| 698 // Allocate the function | 715 // Allocate the function |
| 699 Handle<JSFunction> function = NewFunction(name, the_hole_value()); | 716 Handle<JSFunction> function = NewFunction(name, the_hole_value()); |
| 700 | 717 |
| 701 // Setup the code pointer in both the shared function info and in | 718 // Set up the code pointer in both the shared function info and in |
| 702 // the function itself. | 719 // the function itself. |
| 703 function->shared()->set_code(*code); | 720 function->shared()->set_code(*code); |
| 704 function->set_code(*code); | 721 function->set_code(*code); |
| 705 | 722 |
| 706 if (force_initial_map || | 723 if (force_initial_map || |
| 707 type != JS_OBJECT_TYPE || | 724 type != JS_OBJECT_TYPE || |
| 708 instance_size != JSObject::kHeaderSize) { | 725 instance_size != JSObject::kHeaderSize) { |
| 709 Handle<Map> initial_map = NewMap(type, instance_size); | 726 Handle<Map> initial_map = NewMap(type, instance_size); |
| 710 Handle<JSObject> prototype = NewFunctionPrototype(function); | 727 Handle<JSObject> prototype = NewFunctionPrototype(function); |
| 711 initial_map->set_prototype(*prototype); | 728 initial_map->set_prototype(*prototype); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 722 | 739 |
| 723 Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name, | 740 Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name, |
| 724 InstanceType type, | 741 InstanceType type, |
| 725 int instance_size, | 742 int instance_size, |
| 726 Handle<JSObject> prototype, | 743 Handle<JSObject> prototype, |
| 727 Handle<Code> code, | 744 Handle<Code> code, |
| 728 bool force_initial_map) { | 745 bool force_initial_map) { |
| 729 // Allocate the function. | 746 // Allocate the function. |
| 730 Handle<JSFunction> function = NewFunction(name, prototype); | 747 Handle<JSFunction> function = NewFunction(name, prototype); |
| 731 | 748 |
| 732 // Setup the code pointer in both the shared function info and in | 749 // Set up the code pointer in both the shared function info and in |
| 733 // the function itself. | 750 // the function itself. |
| 734 function->shared()->set_code(*code); | 751 function->shared()->set_code(*code); |
| 735 function->set_code(*code); | 752 function->set_code(*code); |
| 736 | 753 |
| 737 if (force_initial_map || | 754 if (force_initial_map || |
| 738 type != JS_OBJECT_TYPE || | 755 type != JS_OBJECT_TYPE || |
| 739 instance_size != JSObject::kHeaderSize) { | 756 instance_size != JSObject::kHeaderSize) { |
| 740 ElementsKind default_elements_kind = FLAG_smi_only_arrays | 757 ElementsKind default_elements_kind = FLAG_smi_only_arrays |
| 741 ? FAST_SMI_ONLY_ELEMENTS | 758 ? FAST_SMI_ONLY_ELEMENTS |
| 742 : FAST_ELEMENTS; | 759 : FAST_ELEMENTS; |
| 743 Handle<Map> initial_map = NewMap(type, | 760 Handle<Map> initial_map = NewMap(type, |
| 744 instance_size, | 761 instance_size, |
| 745 default_elements_kind); | 762 default_elements_kind); |
| 746 function->set_initial_map(*initial_map); | 763 function->set_initial_map(*initial_map); |
| 747 initial_map->set_constructor(*function); | 764 initial_map->set_constructor(*function); |
| 748 } | 765 } |
| 749 | 766 |
| 750 // Set function.prototype and give the prototype a constructor | 767 // Set function.prototype and give the prototype a constructor |
| 751 // property that refers to the function. | 768 // property that refers to the function. |
| 752 SetPrototypeProperty(function, prototype); | 769 SetPrototypeProperty(function, prototype); |
| 753 // Currently safe because it is only invoked from Genesis. | 770 // Currently safe because it is only invoked from Genesis. |
| 754 SetLocalPropertyNoThrow(prototype, constructor_symbol(), function, DONT_ENUM); | 771 CHECK_NOT_EMPTY_HANDLE(isolate(), |
| 772 JSObject::SetLocalPropertyIgnoreAttributes( |
| 773 prototype, constructor_symbol(), |
| 774 function, DONT_ENUM)); |
| 755 return function; | 775 return function; |
| 756 } | 776 } |
| 757 | 777 |
| 758 | 778 |
| 759 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name, | 779 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name, |
| 760 Handle<Code> code) { | 780 Handle<Code> code) { |
| 761 Handle<JSFunction> function = NewFunctionWithoutPrototype(name, | 781 Handle<JSFunction> function = NewFunctionWithoutPrototype(name, |
| 762 CLASSIC_MODE); | 782 CLASSIC_MODE); |
| 763 function->shared()->set_code(*code); | 783 function->shared()->set_code(*code); |
| 764 function->set_code(*code); | 784 function->set_code(*code); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 isolate()->heap()->NumberToString(*number), String); | 1074 isolate()->heap()->NumberToString(*number), String); |
| 1055 } | 1075 } |
| 1056 | 1076 |
| 1057 | 1077 |
| 1058 Handle<String> Factory::Uint32ToString(uint32_t value) { | 1078 Handle<String> Factory::Uint32ToString(uint32_t value) { |
| 1059 CALL_HEAP_FUNCTION(isolate(), | 1079 CALL_HEAP_FUNCTION(isolate(), |
| 1060 isolate()->heap()->Uint32ToString(value), String); | 1080 isolate()->heap()->Uint32ToString(value), String); |
| 1061 } | 1081 } |
| 1062 | 1082 |
| 1063 | 1083 |
| 1064 Handle<NumberDictionary> Factory::DictionaryAtNumberPut( | 1084 Handle<SeededNumberDictionary> Factory::DictionaryAtNumberPut( |
| 1065 Handle<NumberDictionary> dictionary, | 1085 Handle<SeededNumberDictionary> dictionary, |
| 1066 uint32_t key, | 1086 uint32_t key, |
| 1067 Handle<Object> value) { | 1087 Handle<Object> value) { |
| 1068 CALL_HEAP_FUNCTION(isolate(), | 1088 CALL_HEAP_FUNCTION(isolate(), |
| 1069 dictionary->AtNumberPut(key, *value), | 1089 dictionary->AtNumberPut(key, *value), |
| 1070 NumberDictionary); | 1090 SeededNumberDictionary); |
| 1091 } |
| 1092 |
| 1093 |
| 1094 Handle<UnseededNumberDictionary> Factory::DictionaryAtNumberPut( |
| 1095 Handle<UnseededNumberDictionary> dictionary, |
| 1096 uint32_t key, |
| 1097 Handle<Object> value) { |
| 1098 CALL_HEAP_FUNCTION(isolate(), |
| 1099 dictionary->AtNumberPut(key, *value), |
| 1100 UnseededNumberDictionary); |
| 1071 } | 1101 } |
| 1072 | 1102 |
| 1073 | 1103 |
| 1074 Handle<JSFunction> Factory::NewFunctionHelper(Handle<String> name, | 1104 Handle<JSFunction> Factory::NewFunctionHelper(Handle<String> name, |
| 1075 Handle<Object> prototype) { | 1105 Handle<Object> prototype) { |
| 1076 Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name); | 1106 Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name); |
| 1077 CALL_HEAP_FUNCTION( | 1107 CALL_HEAP_FUNCTION( |
| 1078 isolate(), | 1108 isolate(), |
| 1079 isolate()->heap()->AllocateFunction(*isolate()->function_map(), | 1109 isolate()->heap()->AllocateFunction(*isolate()->function_map(), |
| 1080 *function_share, | 1110 *function_share, |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 | 1411 |
| 1382 | 1412 |
| 1383 Handle<Object> Factory::ToBoolean(bool value) { | 1413 Handle<Object> Factory::ToBoolean(bool value) { |
| 1384 return Handle<Object>(value | 1414 return Handle<Object>(value |
| 1385 ? isolate()->heap()->true_value() | 1415 ? isolate()->heap()->true_value() |
| 1386 : isolate()->heap()->false_value()); | 1416 : isolate()->heap()->false_value()); |
| 1387 } | 1417 } |
| 1388 | 1418 |
| 1389 | 1419 |
| 1390 } } // namespace v8::internal | 1420 } } // namespace v8::internal |
| OLD | NEW |