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); | |
adamk
2017/03/15 21:36:44
There are other fields, don't we need to initializ
gsathya
2017/03/16 00:59:24
Those are set to undefined by default which is val
adamk
2017/03/16 21:41:23
Ah, ok. Can you add comments to both places refere
| |
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 1947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2875 Handle<AccessorInfo> prototype = | 2888 Handle<AccessorInfo> prototype = |
2876 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); | 2889 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); |
2877 Descriptor d = Descriptor::AccessorConstant( | 2890 Descriptor d = Descriptor::AccessorConstant( |
2878 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs); | 2891 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs); |
2879 map->AppendDescriptor(&d); | 2892 map->AppendDescriptor(&d); |
2880 } | 2893 } |
2881 } | 2894 } |
2882 | 2895 |
2883 } // namespace internal | 2896 } // namespace internal |
2884 } // namespace v8 | 2897 } // namespace v8 |
OLD | NEW |