| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 Handle<ObjectHashSet> Factory::NewObjectHashSet(int at_least_space_for) { | 126 Handle<ObjectHashSet> Factory::NewObjectHashSet(int at_least_space_for) { |
| 127 ASSERT(0 <= at_least_space_for); | 127 ASSERT(0 <= at_least_space_for); |
| 128 CALL_HEAP_FUNCTION(isolate(), | 128 CALL_HEAP_FUNCTION(isolate(), |
| 129 ObjectHashSet::Allocate(isolate()->heap(), | 129 ObjectHashSet::Allocate(isolate()->heap(), |
| 130 at_least_space_for), | 130 at_least_space_for), |
| 131 ObjectHashSet); | 131 ObjectHashSet); |
| 132 } | 132 } |
| 133 | 133 |
| 134 | 134 |
| 135 Handle<ObjectHashTable> Factory::NewObjectHashTable(int at_least_space_for) { | 135 Handle<ObjectHashTable> Factory::NewObjectHashTable( |
| 136 int at_least_space_for, |
| 137 MinimumCapacity capacity_option) { |
| 136 ASSERT(0 <= at_least_space_for); | 138 ASSERT(0 <= at_least_space_for); |
| 137 CALL_HEAP_FUNCTION(isolate(), | 139 CALL_HEAP_FUNCTION(isolate(), |
| 138 ObjectHashTable::Allocate(isolate()->heap(), | 140 ObjectHashTable::Allocate(isolate()->heap(), |
| 139 at_least_space_for), | 141 at_least_space_for, |
| 142 capacity_option), |
| 140 ObjectHashTable); | 143 ObjectHashTable); |
| 141 } | 144 } |
| 142 | 145 |
| 143 | 146 |
| 144 Handle<WeakHashTable> Factory::NewWeakHashTable(int at_least_space_for) { | 147 Handle<WeakHashTable> Factory::NewWeakHashTable(int at_least_space_for) { |
| 145 ASSERT(0 <= at_least_space_for); | 148 ASSERT(0 <= at_least_space_for); |
| 146 CALL_HEAP_FUNCTION( | 149 CALL_HEAP_FUNCTION( |
| 147 isolate(), | 150 isolate(), |
| 148 WeakHashTable::Allocate(isolate()->heap(), | 151 WeakHashTable::Allocate(isolate()->heap(), |
| 149 at_least_space_for, | 152 at_least_space_for, |
| 150 WeakHashTable::USE_DEFAULT_MINIMUM_CAPACITY, | 153 USE_DEFAULT_MINIMUM_CAPACITY, |
| 151 TENURED), | 154 TENURED), |
| 152 WeakHashTable); | 155 WeakHashTable); |
| 153 } | 156 } |
| 154 | 157 |
| 155 | 158 |
| 156 Handle<DescriptorArray> Factory::NewDescriptorArray(int number_of_descriptors, | 159 Handle<DescriptorArray> Factory::NewDescriptorArray(int number_of_descriptors, |
| 157 int slack) { | 160 int slack) { |
| 158 ASSERT(0 <= number_of_descriptors); | 161 ASSERT(0 <= number_of_descriptors); |
| 159 CALL_HEAP_FUNCTION(isolate(), | 162 CALL_HEAP_FUNCTION(isolate(), |
| 160 DescriptorArray::Allocate( | 163 DescriptorArray::Allocate( |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 int instance_size, | 569 int instance_size, |
| 567 ElementsKind elements_kind) { | 570 ElementsKind elements_kind) { |
| 568 CALL_HEAP_FUNCTION( | 571 CALL_HEAP_FUNCTION( |
| 569 isolate(), | 572 isolate(), |
| 570 isolate()->heap()->AllocateMap(type, instance_size, elements_kind), | 573 isolate()->heap()->AllocateMap(type, instance_size, elements_kind), |
| 571 Map); | 574 Map); |
| 572 } | 575 } |
| 573 | 576 |
| 574 | 577 |
| 575 Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) { | 578 Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) { |
| 576 CALL_HEAP_FUNCTION( | 579 // Make sure to use globals from the function's context, since the function |
| 577 isolate(), | 580 // can be from a different context. |
| 578 isolate()->heap()->AllocateFunctionPrototype(*function), | 581 Handle<Context> native_context(function->context()->native_context()); |
| 579 JSObject); | 582 Handle<Map> new_map; |
| 583 if (function->shared()->is_generator()) { |
| 584 // Generator prototypes can share maps since they don't have "constructor" |
| 585 // properties. |
| 586 new_map = handle(native_context->generator_object_prototype_map()); |
| 587 } else { |
| 588 // Each function prototype gets a fresh map to avoid unwanted sharing of |
| 589 // maps between prototypes of different constructors. |
| 590 Handle<JSFunction> object_function(native_context->object_function()); |
| 591 ASSERT(object_function->has_initial_map()); |
| 592 new_map = Map::Copy(handle(object_function->initial_map())); |
| 593 } |
| 594 |
| 595 Handle<JSObject> prototype = NewJSObjectFromMap(new_map); |
| 596 |
| 597 if (!function->shared()->is_generator()) { |
| 598 JSObject::SetLocalPropertyIgnoreAttributes(prototype, |
| 599 constructor_string(), |
| 600 function, |
| 601 DONT_ENUM); |
| 602 } |
| 603 |
| 604 return prototype; |
| 580 } | 605 } |
| 581 | 606 |
| 582 | 607 |
| 583 Handle<Map> Factory::CopyWithPreallocatedFieldDescriptors(Handle<Map> src) { | 608 Handle<Map> Factory::CopyWithPreallocatedFieldDescriptors(Handle<Map> src) { |
| 584 CALL_HEAP_FUNCTION( | 609 CALL_HEAP_FUNCTION( |
| 585 isolate(), src->CopyWithPreallocatedFieldDescriptors(), Map); | 610 isolate(), src->CopyWithPreallocatedFieldDescriptors(), Map); |
| 586 } | 611 } |
| 587 | 612 |
| 588 | 613 |
| 589 Handle<Map> Factory::CopyMap(Handle<Map> src, | 614 Handle<Map> Factory::CopyMap(Handle<Map> src, |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 | 1065 |
| 1041 | 1066 |
| 1042 Handle<String> Factory::InternalizedStringFromString(Handle<String> value) { | 1067 Handle<String> Factory::InternalizedStringFromString(Handle<String> value) { |
| 1043 CALL_HEAP_FUNCTION(isolate(), | 1068 CALL_HEAP_FUNCTION(isolate(), |
| 1044 isolate()->heap()->InternalizeString(*value), String); | 1069 isolate()->heap()->InternalizeString(*value), String); |
| 1045 } | 1070 } |
| 1046 | 1071 |
| 1047 | 1072 |
| 1048 Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor, | 1073 Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor, |
| 1049 PretenureFlag pretenure) { | 1074 PretenureFlag pretenure) { |
| 1075 JSFunction::EnsureHasInitialMap(constructor); |
| 1050 CALL_HEAP_FUNCTION( | 1076 CALL_HEAP_FUNCTION( |
| 1051 isolate(), | 1077 isolate(), |
| 1052 isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject); | 1078 isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject); |
| 1053 } | 1079 } |
| 1054 | 1080 |
| 1055 | 1081 |
| 1056 Handle<JSModule> Factory::NewJSModule(Handle<Context> context, | 1082 Handle<JSModule> Factory::NewJSModule(Handle<Context> context, |
| 1057 Handle<ScopeInfo> scope_info) { | 1083 Handle<ScopeInfo> scope_info) { |
| 1058 CALL_HEAP_FUNCTION( | 1084 CALL_HEAP_FUNCTION( |
| 1059 isolate(), | 1085 isolate(), |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 | 1212 |
| 1187 | 1213 |
| 1188 void Factory::SetContent(Handle<JSArray> array, | 1214 void Factory::SetContent(Handle<JSArray> array, |
| 1189 Handle<FixedArrayBase> elements) { | 1215 Handle<FixedArrayBase> elements) { |
| 1190 CALL_HEAP_FUNCTION_VOID( | 1216 CALL_HEAP_FUNCTION_VOID( |
| 1191 isolate(), | 1217 isolate(), |
| 1192 array->SetContent(*elements)); | 1218 array->SetContent(*elements)); |
| 1193 } | 1219 } |
| 1194 | 1220 |
| 1195 | 1221 |
| 1222 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject( |
| 1223 Handle<JSFunction> function) { |
| 1224 ASSERT(function->shared()->is_generator()); |
| 1225 JSFunction::EnsureHasInitialMap(function); |
| 1226 Handle<Map> map(function->initial_map()); |
| 1227 ASSERT(map->instance_type() == JS_GENERATOR_OBJECT_TYPE); |
| 1228 CALL_HEAP_FUNCTION( |
| 1229 isolate(), |
| 1230 isolate()->heap()->AllocateJSObjectFromMap(*map), |
| 1231 JSGeneratorObject); |
| 1232 } |
| 1233 |
| 1234 |
| 1196 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() { | 1235 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() { |
| 1197 Handle<JSFunction> array_buffer_fun( | 1236 Handle<JSFunction> array_buffer_fun( |
| 1198 isolate()->context()->native_context()->array_buffer_fun()); | 1237 isolate()->context()->native_context()->array_buffer_fun()); |
| 1199 CALL_HEAP_FUNCTION( | 1238 CALL_HEAP_FUNCTION( |
| 1200 isolate(), | 1239 isolate(), |
| 1201 isolate()->heap()->AllocateJSObject(*array_buffer_fun), | 1240 isolate()->heap()->AllocateJSObject(*array_buffer_fun), |
| 1202 JSArrayBuffer); | 1241 JSArrayBuffer); |
| 1203 } | 1242 } |
| 1204 | 1243 |
| 1205 | 1244 |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1741 return Handle<Object>::null(); | 1780 return Handle<Object>::null(); |
| 1742 } | 1781 } |
| 1743 | 1782 |
| 1744 | 1783 |
| 1745 Handle<Object> Factory::ToBoolean(bool value) { | 1784 Handle<Object> Factory::ToBoolean(bool value) { |
| 1746 return value ? true_value() : false_value(); | 1785 return value ? true_value() : false_value(); |
| 1747 } | 1786 } |
| 1748 | 1787 |
| 1749 | 1788 |
| 1750 } } // namespace v8::internal | 1789 } } // namespace v8::internal |
| OLD | NEW |