| 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/conversions.h" | 7 #include "src/conversions.h" |
| 8 #include "src/isolate-inl.h" | 8 #include "src/isolate-inl.h" |
| 9 #include "src/macro-assembler.h" | 9 #include "src/macro-assembler.h" |
| 10 | 10 |
| (...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1237 AllocationSpace space = pretenure == TENURED ? OLD_POINTER_SPACE : NEW_SPACE; | 1237 AllocationSpace space = pretenure == TENURED ? OLD_POINTER_SPACE : NEW_SPACE; |
| 1238 Handle<JSFunction> result = New<JSFunction>(map, space); | 1238 Handle<JSFunction> result = New<JSFunction>(map, space); |
| 1239 InitializeFunction(result, info, context); | 1239 InitializeFunction(result, info, context); |
| 1240 return result; | 1240 return result; |
| 1241 } | 1241 } |
| 1242 | 1242 |
| 1243 | 1243 |
| 1244 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, | 1244 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, |
| 1245 Handle<String> name, | 1245 Handle<String> name, |
| 1246 MaybeHandle<Code> code) { | 1246 MaybeHandle<Code> code) { |
| 1247 Handle<Context> context(isolate()->context()->native_context()); | 1247 Handle<Context> context(isolate()->native_context()); |
| 1248 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name, code); | 1248 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name, code); |
| 1249 ASSERT((info->strict_mode() == SLOPPY) && | 1249 ASSERT((info->strict_mode() == SLOPPY) && |
| 1250 (map.is_identical_to(isolate()->sloppy_function_map()) || | 1250 (map.is_identical_to(isolate()->sloppy_function_map()) || |
| 1251 map.is_identical_to( | 1251 map.is_identical_to( |
| 1252 isolate()->sloppy_function_without_prototype_map()) || | 1252 isolate()->sloppy_function_without_prototype_map()) || |
| 1253 map.is_identical_to( | 1253 map.is_identical_to( |
| 1254 isolate()->sloppy_function_with_readonly_prototype_map()))); | 1254 isolate()->sloppy_function_with_readonly_prototype_map()))); |
| 1255 return NewFunction(map, info, context); | 1255 return NewFunction(map, info, context); |
| 1256 } | 1256 } |
| 1257 | 1257 |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1683 ASSERT(map->instance_type() == JS_GENERATOR_OBJECT_TYPE); | 1683 ASSERT(map->instance_type() == JS_GENERATOR_OBJECT_TYPE); |
| 1684 CALL_HEAP_FUNCTION( | 1684 CALL_HEAP_FUNCTION( |
| 1685 isolate(), | 1685 isolate(), |
| 1686 isolate()->heap()->AllocateJSObjectFromMap(*map), | 1686 isolate()->heap()->AllocateJSObjectFromMap(*map), |
| 1687 JSGeneratorObject); | 1687 JSGeneratorObject); |
| 1688 } | 1688 } |
| 1689 | 1689 |
| 1690 | 1690 |
| 1691 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() { | 1691 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() { |
| 1692 Handle<JSFunction> array_buffer_fun( | 1692 Handle<JSFunction> array_buffer_fun( |
| 1693 isolate()->context()->native_context()->array_buffer_fun()); | 1693 isolate()->native_context()->array_buffer_fun()); |
| 1694 CALL_HEAP_FUNCTION( | 1694 CALL_HEAP_FUNCTION( |
| 1695 isolate(), | 1695 isolate(), |
| 1696 isolate()->heap()->AllocateJSObject(*array_buffer_fun), | 1696 isolate()->heap()->AllocateJSObject(*array_buffer_fun), |
| 1697 JSArrayBuffer); | 1697 JSArrayBuffer); |
| 1698 } | 1698 } |
| 1699 | 1699 |
| 1700 | 1700 |
| 1701 Handle<JSDataView> Factory::NewJSDataView() { | 1701 Handle<JSDataView> Factory::NewJSDataView() { |
| 1702 Handle<JSFunction> data_view_fun( | 1702 Handle<JSFunction> data_view_fun( |
| 1703 isolate()->context()->native_context()->data_view_fun()); | 1703 isolate()->native_context()->data_view_fun()); |
| 1704 CALL_HEAP_FUNCTION( | 1704 CALL_HEAP_FUNCTION( |
| 1705 isolate(), | 1705 isolate(), |
| 1706 isolate()->heap()->AllocateJSObject(*data_view_fun), | 1706 isolate()->heap()->AllocateJSObject(*data_view_fun), |
| 1707 JSDataView); | 1707 JSDataView); |
| 1708 } | 1708 } |
| 1709 | 1709 |
| 1710 | 1710 |
| 1711 static JSFunction* GetTypedArrayFun(ExternalArrayType type, | 1711 static JSFunction* GetTypedArrayFun(ExternalArrayType type, |
| 1712 Isolate* isolate) { | 1712 Isolate* isolate) { |
| 1713 Context* native_context = isolate->context()->native_context(); | 1713 Context* native_context = isolate->context()->native_context(); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1817 object->synchronized_set_map(*map); | 1817 object->synchronized_set_map(*map); |
| 1818 Handle<JSObject> jsobj = Handle<JSObject>::cast(object); | 1818 Handle<JSObject> jsobj = Handle<JSObject>::cast(object); |
| 1819 | 1819 |
| 1820 // Reinitialize the object from the constructor map. | 1820 // Reinitialize the object from the constructor map. |
| 1821 heap->InitializeJSObjectFromMap(*jsobj, *properties, *map); | 1821 heap->InitializeJSObjectFromMap(*jsobj, *properties, *map); |
| 1822 | 1822 |
| 1823 // Functions require some minimal initialization. | 1823 // Functions require some minimal initialization. |
| 1824 if (type == JS_FUNCTION_TYPE) { | 1824 if (type == JS_FUNCTION_TYPE) { |
| 1825 map->set_function_with_prototype(true); | 1825 map->set_function_with_prototype(true); |
| 1826 Handle<JSFunction> js_function = Handle<JSFunction>::cast(object); | 1826 Handle<JSFunction> js_function = Handle<JSFunction>::cast(object); |
| 1827 Handle<Context> context(isolate()->context()->native_context()); | 1827 Handle<Context> context(isolate()->native_context()); |
| 1828 InitializeFunction(js_function, shared.ToHandleChecked(), context); | 1828 InitializeFunction(js_function, shared.ToHandleChecked(), context); |
| 1829 } | 1829 } |
| 1830 } | 1830 } |
| 1831 | 1831 |
| 1832 | 1832 |
| 1833 void Factory::ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> object, | 1833 void Factory::ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> object, |
| 1834 Handle<JSFunction> constructor) { | 1834 Handle<JSFunction> constructor) { |
| 1835 ASSERT(constructor->has_initial_map()); | 1835 ASSERT(constructor->has_initial_map()); |
| 1836 Handle<Map> map(constructor->initial_map(), isolate()); | 1836 Handle<Map> map(constructor->initial_map(), isolate()); |
| 1837 | 1837 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2113 ObjectTemplateInfo::cast(obj->instance_template())); | 2113 ObjectTemplateInfo::cast(obj->instance_template())); |
| 2114 internal_field_count = | 2114 internal_field_count = |
| 2115 Smi::cast(instance_template->internal_field_count())->value(); | 2115 Smi::cast(instance_template->internal_field_count())->value(); |
| 2116 } | 2116 } |
| 2117 | 2117 |
| 2118 // TODO(svenpanne) Kill ApiInstanceType and refactor things by generalizing | 2118 // TODO(svenpanne) Kill ApiInstanceType and refactor things by generalizing |
| 2119 // JSObject::GetHeaderSize. | 2119 // JSObject::GetHeaderSize. |
| 2120 int instance_size = kPointerSize * internal_field_count; | 2120 int instance_size = kPointerSize * internal_field_count; |
| 2121 InstanceType type; | 2121 InstanceType type; |
| 2122 switch (instance_type) { | 2122 switch (instance_type) { |
| 2123 case JavaScriptObject: | 2123 case JavaScriptObjectType: |
| 2124 type = JS_OBJECT_TYPE; | 2124 type = JS_OBJECT_TYPE; |
| 2125 instance_size += JSObject::kHeaderSize; | 2125 instance_size += JSObject::kHeaderSize; |
| 2126 break; | 2126 break; |
| 2127 case InnerGlobalObject: | 2127 case GlobalObjectType: |
| 2128 type = JS_GLOBAL_OBJECT_TYPE; | 2128 type = JS_GLOBAL_OBJECT_TYPE; |
| 2129 instance_size += JSGlobalObject::kSize; | 2129 instance_size += JSGlobalObject::kSize; |
| 2130 break; | 2130 break; |
| 2131 case OuterGlobalObject: | 2131 case GlobalProxyType: |
| 2132 type = JS_GLOBAL_PROXY_TYPE; | 2132 type = JS_GLOBAL_PROXY_TYPE; |
| 2133 instance_size += JSGlobalProxy::kSize; | 2133 instance_size += JSGlobalProxy::kSize; |
| 2134 break; | 2134 break; |
| 2135 default: | 2135 default: |
| 2136 UNREACHABLE(); | 2136 UNREACHABLE(); |
| 2137 type = JS_OBJECT_TYPE; // Keep the compiler happy. | 2137 type = JS_OBJECT_TYPE; // Keep the compiler happy. |
| 2138 break; | 2138 break; |
| 2139 } | 2139 } |
| 2140 | 2140 |
| 2141 result = NewFunction(empty_string(), code, prototype, type, | 2141 result = NewFunction(empty_string(), code, prototype, type, |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2360 return Handle<Object>::null(); | 2360 return Handle<Object>::null(); |
| 2361 } | 2361 } |
| 2362 | 2362 |
| 2363 | 2363 |
| 2364 Handle<Object> Factory::ToBoolean(bool value) { | 2364 Handle<Object> Factory::ToBoolean(bool value) { |
| 2365 return value ? true_value() : false_value(); | 2365 return value ? true_value() : false_value(); |
| 2366 } | 2366 } |
| 2367 | 2367 |
| 2368 | 2368 |
| 2369 } } // namespace v8::internal | 2369 } } // namespace v8::internal |
| OLD | NEW |