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