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/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 Symbol); | 909 Symbol); |
910 } | 910 } |
911 | 911 |
912 | 912 |
913 Handle<Symbol> Factory::NewPrivateSymbol() { | 913 Handle<Symbol> Factory::NewPrivateSymbol() { |
914 Handle<Symbol> symbol = NewSymbol(); | 914 Handle<Symbol> symbol = NewSymbol(); |
915 symbol->set_is_private(true); | 915 symbol->set_is_private(true); |
916 return symbol; | 916 return symbol; |
917 } | 917 } |
918 | 918 |
| 919 Handle<JSPromise> Factory::NewJSPromise() { |
| 920 Handle<JSFunction> constructor( |
| 921 isolate()->native_context()->promise_function(), isolate()); |
| 922 DCHECK(constructor->has_initial_map()); |
| 923 Handle<Map> map(constructor->initial_map(), isolate()); |
| 924 |
| 925 DCHECK(!map->is_prototype_map()); |
| 926 Handle<JSObject> promise_obj = NewJSObjectFromMap(map); |
| 927 Handle<JSPromise> promise = Handle<JSPromise>::cast(promise_obj); |
| 928 promise->set_status(v8::Promise::kPending); |
| 929 promise->set_flags(0); |
| 930 |
| 931 isolate()->RunPromiseHook(PromiseHookType::kInit, promise, undefined_value()); |
| 932 return promise; |
| 933 } |
919 | 934 |
920 Handle<Context> Factory::NewNativeContext() { | 935 Handle<Context> Factory::NewNativeContext() { |
921 Handle<FixedArray> array = | 936 Handle<FixedArray> array = |
922 NewFixedArray(Context::NATIVE_CONTEXT_SLOTS, TENURED); | 937 NewFixedArray(Context::NATIVE_CONTEXT_SLOTS, TENURED); |
923 array->set_map_no_write_barrier(*native_context_map()); | 938 array->set_map_no_write_barrier(*native_context_map()); |
924 Handle<Context> context = Handle<Context>::cast(array); | 939 Handle<Context> context = Handle<Context>::cast(array); |
925 context->set_native_context(*context); | 940 context->set_native_context(*context); |
926 context->set_errors_thrown(Smi::kZero); | 941 context->set_errors_thrown(Smi::kZero); |
927 context->set_math_random_index(Smi::kZero); | 942 context->set_math_random_index(Smi::kZero); |
928 Handle<WeakCell> weak_cell = NewWeakCell(context); | 943 Handle<WeakCell> weak_cell = NewWeakCell(context); |
(...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2904 Handle<AccessorInfo> prototype = | 2919 Handle<AccessorInfo> prototype = |
2905 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); | 2920 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); |
2906 Descriptor d = Descriptor::AccessorConstant( | 2921 Descriptor d = Descriptor::AccessorConstant( |
2907 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs); | 2922 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs); |
2908 map->AppendDescriptor(&d); | 2923 map->AppendDescriptor(&d); |
2909 } | 2924 } |
2910 } | 2925 } |
2911 | 2926 |
2912 } // namespace internal | 2927 } // namespace internal |
2913 } // namespace v8 | 2928 } // namespace v8 |
OLD | NEW |