OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 6138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6149 i::Handle<i::JSArray> entry_array = | 6149 i::Handle<i::JSArray> entry_array = |
6150 factory->NewJSArrayWithElements(entry, i::FAST_ELEMENTS, 2); | 6150 factory->NewJSArrayWithElements(entry, i::FAST_ELEMENTS, 2); |
6151 result->set(i, *entry_array); | 6151 result->set(i, *entry_array); |
6152 } | 6152 } |
6153 i::Handle<i::JSArray> result_array = | 6153 i::Handle<i::JSArray> result_array = |
6154 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); | 6154 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); |
6155 return Utils::ToLocal(result_array); | 6155 return Utils::ToLocal(result_array); |
6156 } | 6156 } |
6157 | 6157 |
6158 | 6158 |
| 6159 MaybeLocal<Map> Map::FromArray(Local<Context> context, Local<Array> array) { |
| 6160 PREPARE_FOR_EXECUTION(context, "Map::FromArray", Map); |
| 6161 i::Handle<i::Object> result; |
| 6162 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*array)}; |
| 6163 has_pending_exception = |
| 6164 !i::Execution::Call(isolate, isolate->map_from_array(), |
| 6165 isolate->factory()->undefined_value(), |
| 6166 arraysize(argv), argv, false).ToHandle(&result); |
| 6167 RETURN_ON_FAILED_EXECUTION(Map); |
| 6168 RETURN_ESCAPED(Local<Map>::Cast(Utils::ToLocal(result))); |
| 6169 } |
| 6170 |
| 6171 |
6159 Local<v8::Set> v8::Set::New(Isolate* isolate) { | 6172 Local<v8::Set> v8::Set::New(Isolate* isolate) { |
6160 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6173 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6161 LOG_API(i_isolate, "Set::New"); | 6174 LOG_API(i_isolate, "Set::New"); |
6162 ENTER_V8(i_isolate); | 6175 ENTER_V8(i_isolate); |
6163 i::Handle<i::JSSet> obj = i_isolate->factory()->NewJSSet(); | 6176 i::Handle<i::JSSet> obj = i_isolate->factory()->NewJSSet(); |
6164 return Utils::ToLocal(obj); | 6177 return Utils::ToLocal(obj); |
6165 } | 6178 } |
6166 | 6179 |
6167 | 6180 |
6168 size_t v8::Set::Size() const { | 6181 size_t v8::Set::Size() const { |
(...skipping 16 matching lines...) Expand all Loading... |
6185 if (!key->IsTheHole()) { | 6198 if (!key->IsTheHole()) { |
6186 result->set(i, key); | 6199 result->set(i, key); |
6187 } | 6200 } |
6188 } | 6201 } |
6189 i::Handle<i::JSArray> result_array = | 6202 i::Handle<i::JSArray> result_array = |
6190 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); | 6203 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); |
6191 return Utils::ToLocal(result_array); | 6204 return Utils::ToLocal(result_array); |
6192 } | 6205 } |
6193 | 6206 |
6194 | 6207 |
| 6208 MaybeLocal<Set> Set::FromArray(Local<Context> context, Local<Array> array) { |
| 6209 PREPARE_FOR_EXECUTION(context, "Set::FromArray", Set); |
| 6210 i::Handle<i::Object> result; |
| 6211 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*array)}; |
| 6212 has_pending_exception = |
| 6213 !i::Execution::Call(isolate, isolate->set_from_array(), |
| 6214 isolate->factory()->undefined_value(), |
| 6215 arraysize(argv), argv, false).ToHandle(&result); |
| 6216 RETURN_ON_FAILED_EXECUTION(Set); |
| 6217 RETURN_ESCAPED(Local<Set>::Cast(Utils::ToLocal(result))); |
| 6218 } |
| 6219 |
| 6220 |
6195 bool Value::IsPromise() const { | 6221 bool Value::IsPromise() const { |
6196 auto self = Utils::OpenHandle(this); | 6222 auto self = Utils::OpenHandle(this); |
6197 return i::Object::IsPromise(self); | 6223 return i::Object::IsPromise(self); |
6198 } | 6224 } |
6199 | 6225 |
6200 | 6226 |
6201 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { | 6227 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { |
6202 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver); | 6228 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver); |
6203 i::Handle<i::Object> result; | 6229 i::Handle<i::Object> result; |
6204 has_pending_exception = !i::Execution::Call( | 6230 has_pending_exception = !i::Execution::Call( |
(...skipping 1994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8199 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8225 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
8200 Address callback_address = | 8226 Address callback_address = |
8201 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8227 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8202 VMState<EXTERNAL> state(isolate); | 8228 VMState<EXTERNAL> state(isolate); |
8203 ExternalCallbackScope call_scope(isolate, callback_address); | 8229 ExternalCallbackScope call_scope(isolate, callback_address); |
8204 callback(info); | 8230 callback(info); |
8205 } | 8231 } |
8206 | 8232 |
8207 | 8233 |
8208 } } // namespace v8::internal | 8234 } } // namespace v8::internal |
OLD | NEW |