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 6136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6147 i::Handle<i::JSArray> entry_array = | 6147 i::Handle<i::JSArray> entry_array = |
6148 factory->NewJSArrayWithElements(entry, i::FAST_ELEMENTS, 2); | 6148 factory->NewJSArrayWithElements(entry, i::FAST_ELEMENTS, 2); |
6149 result->set(i, *entry_array); | 6149 result->set(i, *entry_array); |
6150 } | 6150 } |
6151 i::Handle<i::JSArray> result_array = | 6151 i::Handle<i::JSArray> result_array = |
6152 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); | 6152 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); |
6153 return Utils::ToLocal(result_array); | 6153 return Utils::ToLocal(result_array); |
6154 } | 6154 } |
6155 | 6155 |
6156 | 6156 |
| 6157 MaybeLocal<Map> Map::FromArray(Local<Context> context, Local<Array> array) { |
| 6158 PREPARE_FOR_EXECUTION(context, "Map::FromArray", Map); |
| 6159 i::Handle<i::Object> result; |
| 6160 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*array)}; |
| 6161 has_pending_exception = |
| 6162 !i::Execution::Call(isolate, isolate->map_from_array(), |
| 6163 isolate->factory()->undefined_value(), |
| 6164 arraysize(argv), argv, false).ToHandle(&result); |
| 6165 RETURN_ON_FAILED_EXECUTION(Map); |
| 6166 RETURN_ESCAPED(Local<Map>::Cast(Utils::ToLocal(result))); |
| 6167 } |
| 6168 |
| 6169 |
6157 Local<v8::Set> v8::Set::New(Isolate* isolate) { | 6170 Local<v8::Set> v8::Set::New(Isolate* isolate) { |
6158 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6171 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6159 LOG_API(i_isolate, "Set::New"); | 6172 LOG_API(i_isolate, "Set::New"); |
6160 ENTER_V8(i_isolate); | 6173 ENTER_V8(i_isolate); |
6161 i::Handle<i::JSSet> obj = i_isolate->factory()->NewJSSet(); | 6174 i::Handle<i::JSSet> obj = i_isolate->factory()->NewJSSet(); |
6162 return Utils::ToLocal(obj); | 6175 return Utils::ToLocal(obj); |
6163 } | 6176 } |
6164 | 6177 |
6165 | 6178 |
6166 size_t v8::Set::Size() const { | 6179 size_t v8::Set::Size() const { |
(...skipping 16 matching lines...) Expand all Loading... |
6183 if (!key->IsTheHole()) { | 6196 if (!key->IsTheHole()) { |
6184 result->set(i, key); | 6197 result->set(i, key); |
6185 } | 6198 } |
6186 } | 6199 } |
6187 i::Handle<i::JSArray> result_array = | 6200 i::Handle<i::JSArray> result_array = |
6188 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); | 6201 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); |
6189 return Utils::ToLocal(result_array); | 6202 return Utils::ToLocal(result_array); |
6190 } | 6203 } |
6191 | 6204 |
6192 | 6205 |
| 6206 MaybeLocal<Set> Set::FromArray(Local<Context> context, Local<Array> array) { |
| 6207 PREPARE_FOR_EXECUTION(context, "Set::FromArray", Set); |
| 6208 i::Handle<i::Object> result; |
| 6209 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*array)}; |
| 6210 has_pending_exception = |
| 6211 !i::Execution::Call(isolate, isolate->set_from_array(), |
| 6212 isolate->factory()->undefined_value(), |
| 6213 arraysize(argv), argv, false).ToHandle(&result); |
| 6214 RETURN_ON_FAILED_EXECUTION(Set); |
| 6215 RETURN_ESCAPED(Local<Set>::Cast(Utils::ToLocal(result))); |
| 6216 } |
| 6217 |
| 6218 |
6193 bool Value::IsPromise() const { | 6219 bool Value::IsPromise() const { |
6194 auto self = Utils::OpenHandle(this); | 6220 auto self = Utils::OpenHandle(this); |
6195 return i::Object::IsPromise(self); | 6221 return i::Object::IsPromise(self); |
6196 } | 6222 } |
6197 | 6223 |
6198 | 6224 |
6199 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { | 6225 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { |
6200 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver); | 6226 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver); |
6201 i::Handle<i::Object> result; | 6227 i::Handle<i::Object> result; |
6202 has_pending_exception = !i::Execution::Call( | 6228 has_pending_exception = !i::Execution::Call( |
(...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8169 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8195 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
8170 Address callback_address = | 8196 Address callback_address = |
8171 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8197 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8172 VMState<EXTERNAL> state(isolate); | 8198 VMState<EXTERNAL> state(isolate); |
8173 ExternalCallbackScope call_scope(isolate, callback_address); | 8199 ExternalCallbackScope call_scope(isolate, callback_address); |
8174 callback(info); | 8200 callback(info); |
8175 } | 8201 } |
8176 | 8202 |
8177 | 8203 |
8178 } } // namespace v8::internal | 8204 } } // namespace v8::internal |
OLD | NEW |