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 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1655 } | 1655 } |
1656 } | 1656 } |
1657 | 1657 |
1658 array->set_elements(*elms); | 1658 array->set_elements(*elms); |
1659 array->set_length(Smi::FromInt(length)); | 1659 array->set_length(Smi::FromInt(length)); |
1660 } | 1660 } |
1661 | 1661 |
1662 | 1662 |
1663 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject( | 1663 Handle<JSGeneratorObject> Factory::NewJSGeneratorObject( |
1664 Handle<JSFunction> function) { | 1664 Handle<JSFunction> function) { |
1665 DCHECK(function->shared()->is_generator()); | 1665 DCHECK(function->shared()->is_resumable()); |
1666 JSFunction::EnsureHasInitialMap(function); | 1666 JSFunction::EnsureHasInitialMap(function); |
1667 Handle<Map> map(function->initial_map()); | 1667 Handle<Map> map(function->initial_map()); |
1668 DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type()); | 1668 DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type()); |
1669 CALL_HEAP_FUNCTION( | 1669 CALL_HEAP_FUNCTION( |
1670 isolate(), | 1670 isolate(), |
1671 isolate()->heap()->AllocateJSObjectFromMap(*map), | 1671 isolate()->heap()->AllocateJSObjectFromMap(*map), |
1672 JSGeneratorObject); | 1672 JSGeneratorObject); |
1673 } | 1673 } |
1674 | 1674 |
1675 | 1675 |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2061 DCHECK(IsValidFunctionKind(kind)); | 2061 DCHECK(IsValidFunctionKind(kind)); |
2062 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo( | 2062 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo( |
2063 name, code, IsConstructable(kind, scope_info->language_mode())); | 2063 name, code, IsConstructable(kind, scope_info->language_mode())); |
2064 shared->set_scope_info(*scope_info); | 2064 shared->set_scope_info(*scope_info); |
2065 shared->set_kind(kind); | 2065 shared->set_kind(kind); |
2066 shared->set_num_literals(number_of_literals); | 2066 shared->set_num_literals(number_of_literals); |
2067 if (IsGeneratorFunction(kind)) { | 2067 if (IsGeneratorFunction(kind)) { |
2068 shared->set_instance_class_name(isolate()->heap()->Generator_string()); | 2068 shared->set_instance_class_name(isolate()->heap()->Generator_string()); |
2069 shared->DisableOptimization(kGenerator); | 2069 shared->DisableOptimization(kGenerator); |
2070 } | 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 } |
2071 return shared; | 2076 return shared; |
2072 } | 2077 } |
2073 | 2078 |
2074 | 2079 |
2075 Handle<JSMessageObject> Factory::NewJSMessageObject( | 2080 Handle<JSMessageObject> Factory::NewJSMessageObject( |
2076 MessageTemplate::Template message, Handle<Object> argument, | 2081 MessageTemplate::Template message, Handle<Object> argument, |
2077 int start_position, int end_position, Handle<Object> script, | 2082 int start_position, int end_position, Handle<Object> script, |
2078 Handle<Object> stack_frames) { | 2083 Handle<Object> stack_frames) { |
2079 Handle<Map> map = message_object_map(); | 2084 Handle<Map> map = message_object_map(); |
2080 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... |
2373 } | 2378 } |
2374 | 2379 |
2375 | 2380 |
2376 Handle<Object> Factory::ToBoolean(bool value) { | 2381 Handle<Object> Factory::ToBoolean(bool value) { |
2377 return value ? true_value() : false_value(); | 2382 return value ? true_value() : false_value(); |
2378 } | 2383 } |
2379 | 2384 |
2380 | 2385 |
2381 } // namespace internal | 2386 } // namespace internal |
2382 } // namespace v8 | 2387 } // namespace v8 |
OLD | NEW |