| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 SinkChar* sink = result->GetChars(); | 303 SinkChar* sink = result->GetChars(); |
| 301 String::WriteToFlat(*first, sink, 0, first->length()); | 304 String::WriteToFlat(*first, sink, 0, first->length()); |
| 302 String::WriteToFlat(*second, sink + first->length(), 0, second->length()); | 305 String::WriteToFlat(*second, sink + first->length(), 0, second->length()); |
| 303 return result; | 306 return result; |
| 304 } | 307 } |
| 305 | 308 |
| 306 | 309 |
| 307 Handle<String> Factory::NewFlatConcatString(Handle<String> first, | 310 Handle<String> Factory::NewFlatConcatString(Handle<String> first, |
| 308 Handle<String> second) { | 311 Handle<String> second) { |
| 309 int total_length = first->length() + second->length(); | 312 int total_length = first->length() + second->length(); |
| 310 if (first->IsOneByteRepresentationUnderneath() && | 313 if (first->IsOneByteRepresentation() && second->IsOneByteRepresentation()) { |
| 311 second->IsOneByteRepresentationUnderneath()) { | |
| 312 return ConcatStringContent<uint8_t>( | 314 return ConcatStringContent<uint8_t>( |
| 313 NewRawOneByteString(total_length), first, second); | 315 NewRawOneByteString(total_length), first, second); |
| 314 } else { | 316 } else { |
| 315 return ConcatStringContent<uc16>( | 317 return ConcatStringContent<uc16>( |
| 316 NewRawTwoByteString(total_length), first, second); | 318 NewRawTwoByteString(total_length), first, second); |
| 317 } | 319 } |
| 318 } | 320 } |
| 319 | 321 |
| 320 | 322 |
| 321 Handle<String> Factory::NewSubString(Handle<String> str, | 323 Handle<String> Factory::NewSubString(Handle<String> str, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 358 |
| 357 | 359 |
| 358 Handle<Symbol> Factory::NewSymbol() { | 360 Handle<Symbol> Factory::NewSymbol() { |
| 359 CALL_HEAP_FUNCTION( | 361 CALL_HEAP_FUNCTION( |
| 360 isolate(), | 362 isolate(), |
| 361 isolate()->heap()->AllocateSymbol(), | 363 isolate()->heap()->AllocateSymbol(), |
| 362 Symbol); | 364 Symbol); |
| 363 } | 365 } |
| 364 | 366 |
| 365 | 367 |
| 368 Handle<Symbol> Factory::NewPrivateSymbol() { |
| 369 CALL_HEAP_FUNCTION( |
| 370 isolate(), |
| 371 isolate()->heap()->AllocatePrivateSymbol(), |
| 372 Symbol); |
| 373 } |
| 374 |
| 375 |
| 366 Handle<Context> Factory::NewNativeContext() { | 376 Handle<Context> Factory::NewNativeContext() { |
| 367 CALL_HEAP_FUNCTION( | 377 CALL_HEAP_FUNCTION( |
| 368 isolate(), | 378 isolate(), |
| 369 isolate()->heap()->AllocateNativeContext(), | 379 isolate()->heap()->AllocateNativeContext(), |
| 370 Context); | 380 Context); |
| 371 } | 381 } |
| 372 | 382 |
| 373 | 383 |
| 374 Handle<Context> Factory::NewGlobalContext(Handle<JSFunction> function, | 384 Handle<Context> Factory::NewGlobalContext(Handle<JSFunction> function, |
| 375 Handle<ScopeInfo> scope_info) { | 385 Handle<ScopeInfo> scope_info) { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 int instance_size, | 576 int instance_size, |
| 567 ElementsKind elements_kind) { | 577 ElementsKind elements_kind) { |
| 568 CALL_HEAP_FUNCTION( | 578 CALL_HEAP_FUNCTION( |
| 569 isolate(), | 579 isolate(), |
| 570 isolate()->heap()->AllocateMap(type, instance_size, elements_kind), | 580 isolate()->heap()->AllocateMap(type, instance_size, elements_kind), |
| 571 Map); | 581 Map); |
| 572 } | 582 } |
| 573 | 583 |
| 574 | 584 |
| 575 Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) { | 585 Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) { |
| 576 CALL_HEAP_FUNCTION( | 586 // Make sure to use globals from the function's context, since the function |
| 577 isolate(), | 587 // can be from a different context. |
| 578 isolate()->heap()->AllocateFunctionPrototype(*function), | 588 Handle<Context> native_context(function->context()->native_context()); |
| 579 JSObject); | 589 Handle<Map> new_map; |
| 590 if (function->shared()->is_generator()) { |
| 591 // Generator prototypes can share maps since they don't have "constructor" |
| 592 // properties. |
| 593 new_map = handle(native_context->generator_object_prototype_map()); |
| 594 } else { |
| 595 // Each function prototype gets a fresh map to avoid unwanted sharing of |
| 596 // maps between prototypes of different constructors. |
| 597 Handle<JSFunction> object_function(native_context->object_function()); |
| 598 ASSERT(object_function->has_initial_map()); |
| 599 new_map = Map::Copy(handle(object_function->initial_map())); |
| 600 } |
| 601 |
| 602 Handle<JSObject> prototype = NewJSObjectFromMap(new_map); |
| 603 |
| 604 if (!function->shared()->is_generator()) { |
| 605 JSObject::SetLocalPropertyIgnoreAttributes(prototype, |
| 606 constructor_string(), |
| 607 function, |
| 608 DONT_ENUM); |
| 609 } |
| 610 |
| 611 return prototype; |
| 580 } | 612 } |
| 581 | 613 |
| 582 | 614 |
| 583 Handle<Map> Factory::CopyWithPreallocatedFieldDescriptors(Handle<Map> src) { | 615 Handle<Map> Factory::CopyWithPreallocatedFieldDescriptors(Handle<Map> src) { |
| 584 CALL_HEAP_FUNCTION( | 616 CALL_HEAP_FUNCTION( |
| 585 isolate(), src->CopyWithPreallocatedFieldDescriptors(), Map); | 617 isolate(), src->CopyWithPreallocatedFieldDescriptors(), Map); |
| 586 } | 618 } |
| 587 | 619 |
| 588 | 620 |
| 589 Handle<Map> Factory::CopyMap(Handle<Map> src, | 621 Handle<Map> Factory::CopyMap(Handle<Map> src, |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 | 1072 |
| 1041 | 1073 |
| 1042 Handle<String> Factory::InternalizedStringFromString(Handle<String> value) { | 1074 Handle<String> Factory::InternalizedStringFromString(Handle<String> value) { |
| 1043 CALL_HEAP_FUNCTION(isolate(), | 1075 CALL_HEAP_FUNCTION(isolate(), |
| 1044 isolate()->heap()->InternalizeString(*value), String); | 1076 isolate()->heap()->InternalizeString(*value), String); |
| 1045 } | 1077 } |
| 1046 | 1078 |
| 1047 | 1079 |
| 1048 Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor, | 1080 Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor, |
| 1049 PretenureFlag pretenure) { | 1081 PretenureFlag pretenure) { |
| 1082 JSFunction::EnsureHasInitialMap(constructor); |
| 1050 CALL_HEAP_FUNCTION( | 1083 CALL_HEAP_FUNCTION( |
| 1051 isolate(), | 1084 isolate(), |
| 1052 isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject); | 1085 isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject); |
| 1053 } | 1086 } |
| 1054 | 1087 |
| 1055 | 1088 |
| 1056 Handle<JSModule> Factory::NewJSModule(Handle<Context> context, | 1089 Handle<JSModule> Factory::NewJSModule(Handle<Context> context, |
| 1057 Handle<ScopeInfo> scope_info) { | 1090 Handle<ScopeInfo> scope_info) { |
| 1058 CALL_HEAP_FUNCTION( | 1091 CALL_HEAP_FUNCTION( |
| 1059 isolate(), | 1092 isolate(), |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 | 1219 |
| 1187 | 1220 |
| 1188 void Factory::SetContent(Handle<JSArray> array, | 1221 void Factory::SetContent(Handle<JSArray> array, |
| 1189 Handle<FixedArrayBase> elements) { | 1222 Handle<FixedArrayBase> elements) { |
| 1190 CALL_HEAP_FUNCTION_VOID( | 1223 CALL_HEAP_FUNCTION_VOID( |
| 1191 isolate(), | 1224 isolate(), |
| 1192 array->SetContent(*elements)); | 1225 array->SetContent(*elements)); |
| 1193 } | 1226 } |
| 1194 | 1227 |
| 1195 | 1228 |
| 1229 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject( |
| 1230 Handle<JSFunction> function) { |
| 1231 ASSERT(function->shared()->is_generator()); |
| 1232 JSFunction::EnsureHasInitialMap(function); |
| 1233 Handle<Map> map(function->initial_map()); |
| 1234 ASSERT(map->instance_type() == JS_GENERATOR_OBJECT_TYPE); |
| 1235 CALL_HEAP_FUNCTION( |
| 1236 isolate(), |
| 1237 isolate()->heap()->AllocateJSObjectFromMap(*map), |
| 1238 JSGeneratorObject); |
| 1239 } |
| 1240 |
| 1241 |
| 1196 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() { | 1242 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() { |
| 1197 Handle<JSFunction> array_buffer_fun( | 1243 Handle<JSFunction> array_buffer_fun( |
| 1198 isolate()->context()->native_context()->array_buffer_fun()); | 1244 isolate()->context()->native_context()->array_buffer_fun()); |
| 1199 CALL_HEAP_FUNCTION( | 1245 CALL_HEAP_FUNCTION( |
| 1200 isolate(), | 1246 isolate(), |
| 1201 isolate()->heap()->AllocateJSObject(*array_buffer_fun), | 1247 isolate()->heap()->AllocateJSObject(*array_buffer_fun), |
| 1202 JSArrayBuffer); | 1248 JSArrayBuffer); |
| 1203 } | 1249 } |
| 1204 | 1250 |
| 1205 | 1251 |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1741 return Handle<Object>::null(); | 1787 return Handle<Object>::null(); |
| 1742 } | 1788 } |
| 1743 | 1789 |
| 1744 | 1790 |
| 1745 Handle<Object> Factory::ToBoolean(bool value) { | 1791 Handle<Object> Factory::ToBoolean(bool value) { |
| 1746 return value ? true_value() : false_value(); | 1792 return value ? true_value() : false_value(); |
| 1747 } | 1793 } |
| 1748 | 1794 |
| 1749 | 1795 |
| 1750 } } // namespace v8::internal | 1796 } } // namespace v8::internal |
| OLD | NEW |