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 6475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6486 } | 6486 } |
6487 | 6487 |
6488 | 6488 |
6489 Local<Array> Set::AsArray() const { | 6489 Local<Array> Set::AsArray() const { |
6490 i::Handle<i::JSSet> obj = Utils::OpenHandle(this); | 6490 i::Handle<i::JSSet> obj = Utils::OpenHandle(this); |
6491 i::Isolate* isolate = obj->GetIsolate(); | 6491 i::Isolate* isolate = obj->GetIsolate(); |
6492 i::Factory* factory = isolate->factory(); | 6492 i::Factory* factory = isolate->factory(); |
6493 LOG_API(isolate, "Set::AsArray"); | 6493 LOG_API(isolate, "Set::AsArray"); |
6494 ENTER_V8(isolate); | 6494 ENTER_V8(isolate); |
6495 i::Handle<i::OrderedHashSet> table(i::OrderedHashSet::cast(obj->table())); | 6495 i::Handle<i::OrderedHashSet> table(i::OrderedHashSet::cast(obj->table())); |
| 6496 int capacity = table->UsedCapacity(); |
6496 int length = table->NumberOfElements(); | 6497 int length = table->NumberOfElements(); |
6497 i::Handle<i::FixedArray> result = factory->NewFixedArray(length); | 6498 i::Handle<i::FixedArray> result = factory->NewFixedArray(length); |
6498 for (int i = 0; i < length; ++i) { | 6499 int result_index = 0; |
| 6500 for (int i = 0; i < capacity; ++i) { |
6499 i::Object* key = table->KeyAt(i); | 6501 i::Object* key = table->KeyAt(i); |
6500 if (!key->IsTheHole()) { | 6502 if (!key->IsTheHole()) { |
6501 result->set(i, key); | 6503 result->set(result_index++, key); |
6502 } | 6504 } |
6503 } | 6505 } |
| 6506 DCHECK_EQ(result_index, result->length()); |
| 6507 DCHECK_EQ(result_index, length); |
6504 i::Handle<i::JSArray> result_array = | 6508 i::Handle<i::JSArray> result_array = |
6505 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); | 6509 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); |
6506 return Utils::ToLocal(result_array); | 6510 return Utils::ToLocal(result_array); |
6507 } | 6511 } |
6508 | 6512 |
6509 | 6513 |
6510 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { | 6514 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { |
6511 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver); | 6515 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver); |
6512 i::Handle<i::Object> result; | 6516 i::Handle<i::Object> result; |
6513 has_pending_exception = | 6517 has_pending_exception = |
(...skipping 2335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8849 Address callback_address = | 8853 Address callback_address = |
8850 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8854 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8851 VMState<EXTERNAL> state(isolate); | 8855 VMState<EXTERNAL> state(isolate); |
8852 ExternalCallbackScope call_scope(isolate, callback_address); | 8856 ExternalCallbackScope call_scope(isolate, callback_address); |
8853 callback(info); | 8857 callback(info); |
8854 } | 8858 } |
8855 | 8859 |
8856 | 8860 |
8857 } // namespace internal | 8861 } // namespace internal |
8858 } // namespace v8 | 8862 } // namespace v8 |
OLD | NEW |