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/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 Handle<SharedFunctionInfo> info = | 1221 Handle<SharedFunctionInfo> info = |
1222 NewSharedFunctionInfo(name, code, map->is_constructor()); | 1222 NewSharedFunctionInfo(name, code, map->is_constructor()); |
1223 DCHECK(is_sloppy(info->language_mode())); | 1223 DCHECK(is_sloppy(info->language_mode())); |
1224 DCHECK(!map->IsUndefined()); | 1224 DCHECK(!map->IsUndefined()); |
1225 DCHECK( | 1225 DCHECK( |
1226 map.is_identical_to(isolate()->sloppy_function_map()) || | 1226 map.is_identical_to(isolate()->sloppy_function_map()) || |
1227 map.is_identical_to(isolate()->sloppy_function_without_prototype_map()) || | 1227 map.is_identical_to(isolate()->sloppy_function_without_prototype_map()) || |
1228 map.is_identical_to( | 1228 map.is_identical_to( |
1229 isolate()->sloppy_function_with_readonly_prototype_map()) || | 1229 isolate()->sloppy_function_with_readonly_prototype_map()) || |
1230 map.is_identical_to(isolate()->strict_function_map()) || | 1230 map.is_identical_to(isolate()->strict_function_map()) || |
| 1231 map.is_identical_to(isolate()->strict_function_without_prototype_map()) || |
1231 // TODO(titzer): wasm_function_map() could be undefined here. ugly. | 1232 // TODO(titzer): wasm_function_map() could be undefined here. ugly. |
1232 (*map == context->get(Context::WASM_FUNCTION_MAP_INDEX)) || | 1233 (*map == context->get(Context::WASM_FUNCTION_MAP_INDEX)) || |
1233 map.is_identical_to(isolate()->proxy_function_map())); | 1234 map.is_identical_to(isolate()->proxy_function_map())); |
1234 return NewFunction(map, info, context); | 1235 return NewFunction(map, info, context); |
1235 } | 1236 } |
1236 | 1237 |
1237 | 1238 |
1238 Handle<JSFunction> Factory::NewFunction(Handle<String> name) { | 1239 Handle<JSFunction> Factory::NewFunction(Handle<String> name) { |
1239 return NewFunction( | 1240 return NewFunction( |
1240 isolate()->sloppy_function_map(), name, MaybeHandle<Code>()); | 1241 isolate()->sloppy_function_map(), name, MaybeHandle<Code>()); |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 } | 1655 } |
1655 } | 1656 } |
1656 | 1657 |
1657 array->set_elements(*elms); | 1658 array->set_elements(*elms); |
1658 array->set_length(Smi::FromInt(length)); | 1659 array->set_length(Smi::FromInt(length)); |
1659 } | 1660 } |
1660 | 1661 |
1661 | 1662 |
1662 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject( | 1663 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject( |
1663 Handle<JSFunction> function) { | 1664 Handle<JSFunction> function) { |
1664 DCHECK(function->shared()->is_generator()); | 1665 DCHECK(function->shared()->is_resumable()); |
1665 JSFunction::EnsureHasInitialMap(function); | 1666 JSFunction::EnsureHasInitialMap(function); |
1666 Handle<Map> map(function->initial_map()); | 1667 Handle<Map> map(function->initial_map()); |
1667 DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type()); | 1668 DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type()); |
1668 CALL_HEAP_FUNCTION( | 1669 CALL_HEAP_FUNCTION( |
1669 isolate(), | 1670 isolate(), |
1670 isolate()->heap()->AllocateJSObjectFromMap(*map), | 1671 isolate()->heap()->AllocateJSObjectFromMap(*map), |
1671 JSGeneratorObject); | 1672 JSGeneratorObject); |
1672 } | 1673 } |
1673 | 1674 |
1674 | 1675 |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2060 DCHECK(IsValidFunctionKind(kind)); | 2061 DCHECK(IsValidFunctionKind(kind)); |
2061 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo( | 2062 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo( |
2062 name, code, IsConstructable(kind, scope_info->language_mode())); | 2063 name, code, IsConstructable(kind, scope_info->language_mode())); |
2063 shared->set_scope_info(*scope_info); | 2064 shared->set_scope_info(*scope_info); |
2064 shared->set_kind(kind); | 2065 shared->set_kind(kind); |
2065 shared->set_num_literals(number_of_literals); | 2066 shared->set_num_literals(number_of_literals); |
2066 if (IsGeneratorFunction(kind)) { | 2067 if (IsGeneratorFunction(kind)) { |
2067 shared->set_instance_class_name(isolate()->heap()->Generator_string()); | 2068 shared->set_instance_class_name(isolate()->heap()->Generator_string()); |
2068 shared->DisableOptimization(kGenerator); | 2069 shared->DisableOptimization(kGenerator); |
2069 } | 2070 } |
| 2071 if (IsAsyncFunction(kind)) { |
| 2072 // TODO(caitp): Enable optimization of async functions when they are enabled |
| 2073 // for generators functions. |
| 2074 shared->DisableOptimization(kGenerator); |
| 2075 } |
2070 return shared; | 2076 return shared; |
2071 } | 2077 } |
2072 | 2078 |
2073 | 2079 |
2074 Handle<JSMessageObject> Factory::NewJSMessageObject( | 2080 Handle<JSMessageObject> Factory::NewJSMessageObject( |
2075 MessageTemplate::Template message, Handle<Object> argument, | 2081 MessageTemplate::Template message, Handle<Object> argument, |
2076 int start_position, int end_position, Handle<Object> script, | 2082 int start_position, int end_position, Handle<Object> script, |
2077 Handle<Object> stack_frames) { | 2083 Handle<Object> stack_frames) { |
2078 Handle<Map> map = message_object_map(); | 2084 Handle<Map> map = message_object_map(); |
2079 Handle<JSMessageObject> message_obj = New<JSMessageObject>(map, NEW_SPACE); | 2085 Handle<JSMessageObject> message_obj = New<JSMessageObject>(map, NEW_SPACE); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2372 } | 2378 } |
2373 | 2379 |
2374 | 2380 |
2375 Handle<Object> Factory::ToBoolean(bool value) { | 2381 Handle<Object> Factory::ToBoolean(bool value) { |
2376 return value ? true_value() : false_value(); | 2382 return value ? true_value() : false_value(); |
2377 } | 2383 } |
2378 | 2384 |
2379 | 2385 |
2380 } // namespace internal | 2386 } // namespace internal |
2381 } // namespace v8 | 2387 } // namespace v8 |
OLD | NEW |