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 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 Symbol); | 908 Symbol); |
909 } | 909 } |
910 | 910 |
911 | 911 |
912 Handle<Symbol> Factory::NewPrivateSymbol() { | 912 Handle<Symbol> Factory::NewPrivateSymbol() { |
913 Handle<Symbol> symbol = NewSymbol(); | 913 Handle<Symbol> symbol = NewSymbol(); |
914 symbol->set_is_private(true); | 914 symbol->set_is_private(true); |
915 return symbol; | 915 return symbol; |
916 } | 916 } |
917 | 917 |
| 918 Handle<JSPromise> Factory::NewJSPromise() { |
| 919 Handle<JSFunction> constructor( |
| 920 isolate()->native_context()->promise_function(), isolate()); |
| 921 DCHECK(constructor->has_initial_map()); |
| 922 Handle<Map> map(constructor->initial_map(), isolate()); |
| 923 |
| 924 DCHECK(!map->is_prototype_map()); |
| 925 Handle<JSObject> promise_obj = NewJSObjectFromMap(map); |
| 926 Handle<JSPromise> promise = Handle<JSPromise>::cast(promise_obj); |
| 927 promise->set_status(v8::Promise::kPending); |
| 928 promise->set_flags(0); |
| 929 return promise; |
| 930 } |
918 | 931 |
919 Handle<Context> Factory::NewNativeContext() { | 932 Handle<Context> Factory::NewNativeContext() { |
920 Handle<FixedArray> array = | 933 Handle<FixedArray> array = |
921 NewFixedArray(Context::NATIVE_CONTEXT_SLOTS, TENURED); | 934 NewFixedArray(Context::NATIVE_CONTEXT_SLOTS, TENURED); |
922 array->set_map_no_write_barrier(*native_context_map()); | 935 array->set_map_no_write_barrier(*native_context_map()); |
923 Handle<Context> context = Handle<Context>::cast(array); | 936 Handle<Context> context = Handle<Context>::cast(array); |
924 context->set_native_context(*context); | 937 context->set_native_context(*context); |
925 context->set_errors_thrown(Smi::kZero); | 938 context->set_errors_thrown(Smi::kZero); |
926 context->set_math_random_index(Smi::kZero); | 939 context->set_math_random_index(Smi::kZero); |
927 Handle<WeakCell> weak_cell = NewWeakCell(context); | 940 Handle<WeakCell> weak_cell = NewWeakCell(context); |
(...skipping 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2885 Handle<AccessorInfo> prototype = | 2898 Handle<AccessorInfo> prototype = |
2886 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); | 2899 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); |
2887 Descriptor d = Descriptor::AccessorConstant( | 2900 Descriptor d = Descriptor::AccessorConstant( |
2888 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs); | 2901 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs); |
2889 map->AppendDescriptor(&d); | 2902 map->AppendDescriptor(&d); |
2890 } | 2903 } |
2891 } | 2904 } |
2892 | 2905 |
2893 } // namespace internal | 2906 } // namespace internal |
2894 } // namespace v8 | 2907 } // namespace v8 |
OLD | NEW |