Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index e0caca6f664a820382bde5c73b726891e6de45a3..2e82e05c99dfbd9a5b6e684b64dc6421f968dd0c 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -1052,49 +1052,6 @@ int NeanderObject::size() { |
} |
-NeanderArray::NeanderArray(v8::internal::Isolate* isolate) : obj_(isolate, 2) { |
- obj_.set(0, i::Smi::FromInt(0)); |
-} |
- |
- |
-int NeanderArray::length() { |
- return i::Smi::cast(obj_.get(0))->value(); |
-} |
- |
- |
-i::Object* NeanderArray::get(int offset) { |
- DCHECK_LE(0, offset); |
- DCHECK_LT(offset, length()); |
- return obj_.get(offset + 1); |
-} |
- |
- |
-// This method cannot easily return an error value, therefore it is necessary |
-// to check for a dead VM with ON_BAILOUT before calling it. To remind you |
-// about this there is no HandleScope in this method. When you add one to the |
-// site calling this method you should check that you ensured the VM was not |
-// dead first. |
-void NeanderArray::add(i::Isolate* isolate, i::Handle<i::Object> value) { |
- int length = this->length(); |
- int size = obj_.size(); |
- if (length == size - 1) { |
- i::Factory* factory = isolate->factory(); |
- i::Handle<i::FixedArray> new_elms = factory->NewFixedArray(2 * size); |
- for (int i = 0; i < length; i++) |
- new_elms->set(i + 1, get(i)); |
- obj_.value()->set_elements(*new_elms); |
- } |
- obj_.set(length + 1, *value); |
- obj_.set(0, i::Smi::FromInt(length + 1)); |
-} |
- |
- |
-void NeanderArray::set(int index, i::Object* value) { |
- if (index < 0 || index >= this->length()) return; |
- obj_.set(index + 1, value); |
-} |
- |
- |
// --- T e m p l a t e --- |
@@ -7982,12 +7939,13 @@ bool Isolate::AddMessageListener(MessageCallback that, Local<Value> data) { |
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
ENTER_V8(isolate); |
i::HandleScope scope(isolate); |
- NeanderArray listeners(isolate->factory()->message_listeners()); |
+ i::Handle<i::TemplateList> list = isolate->factory()->message_listeners(); |
NeanderObject obj(isolate, 2); |
obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that))); |
obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value() |
: *Utils::OpenHandle(*data)); |
- listeners.add(isolate, obj.value()); |
+ list = i::TemplateList::Add(isolate, list, obj.value()); |
+ isolate->heap()->SetMessageListeners(*list); |
return true; |
} |
@@ -7996,14 +7954,15 @@ void Isolate::RemoveMessageListeners(MessageCallback that) { |
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
ENTER_V8(isolate); |
i::HandleScope scope(isolate); |
- NeanderArray listeners(isolate->factory()->message_listeners()); |
- for (int i = 0; i < listeners.length(); i++) { |
- if (listeners.get(i)->IsUndefined(isolate)) continue; // skip deleted ones |
+ i::DisallowHeapAllocation no_gc; |
+ i::TemplateList* listeners = isolate->heap()->message_listeners(); |
+ for (int i = 0; i < listeners->length(); i++) { |
+ if (listeners->get(i)->IsUndefined(isolate)) continue; // skip deleted ones |
- NeanderObject listener(i::JSObject::cast(listeners.get(i))); |
- i::Handle<i::Foreign> callback_obj(i::Foreign::cast(listener.get(0))); |
+ NeanderObject listener(i::JSObject::cast(listeners->get(i))); |
+ i::Foreign* callback_obj = i::Foreign::cast(listener.get(0)); |
if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) { |
- listeners.set(i, isolate->heap()->undefined_value()); |
+ listeners->set(i, isolate->heap()->undefined_value()); |
} |
} |
} |