Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: src/api.cc

Issue 2195243003: [api] Remove NeanderObject (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2016-07-29_api_remove_NeanderArray_2196533003
Patch Set: fixing rebase issues Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/api.h ('k') | src/messages.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 1024
1025 1025
1026 void Context::SetAlignedPointerInEmbedderData(int index, void* value) { 1026 void Context::SetAlignedPointerInEmbedderData(int index, void* value) {
1027 const char* location = "v8::Context::SetAlignedPointerInEmbedderData()"; 1027 const char* location = "v8::Context::SetAlignedPointerInEmbedderData()";
1028 i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, true, location); 1028 i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, true, location);
1029 data->set(index, EncodeAlignedAsSmi(value, location)); 1029 data->set(index, EncodeAlignedAsSmi(value, location));
1030 DCHECK_EQ(value, GetAlignedPointerFromEmbedderData(index)); 1030 DCHECK_EQ(value, GetAlignedPointerFromEmbedderData(index));
1031 } 1031 }
1032 1032
1033 1033
1034 // --- N e a n d e r ---
1035
1036
1037 // A constructor cannot easily return an error value, therefore it is necessary
1038 // to check for a dead VM with ON_BAILOUT before constructing any Neander
1039 // objects. To remind you about this there is no HandleScope in the
1040 // NeanderObject constructor. When you add one to the site calling the
1041 // constructor you should check that you ensured the VM was not dead first.
1042 NeanderObject::NeanderObject(v8::internal::Isolate* isolate, int size) {
1043 ENTER_V8(isolate);
1044 value_ = isolate->factory()->NewNeanderObject();
1045 i::Handle<i::FixedArray> elements = isolate->factory()->NewFixedArray(size);
1046 value_->set_elements(*elements);
1047 }
1048
1049
1050 int NeanderObject::size() {
1051 return i::FixedArray::cast(value_->elements())->length();
1052 }
1053
1054
1055 // --- T e m p l a t e --- 1034 // --- T e m p l a t e ---
1056 1035
1057 1036
1058 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) { 1037 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) {
1059 that->set_number_of_properties(0); 1038 that->set_number_of_properties(0);
1060 that->set_tag(i::Smi::FromInt(type)); 1039 that->set_tag(i::Smi::FromInt(type));
1061 } 1040 }
1062 1041
1063 1042
1064 void Template::Set(v8::Local<Name> name, v8::Local<Data> value, 1043 void Template::Set(v8::Local<Name> name, v8::Local<Data> value,
(...skipping 6868 matching lines...) Expand 10 before | Expand all | Expand 10 after
7933 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 7912 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
7934 return isolate->IsDead(); 7913 return isolate->IsDead();
7935 } 7914 }
7936 7915
7937 7916
7938 bool Isolate::AddMessageListener(MessageCallback that, Local<Value> data) { 7917 bool Isolate::AddMessageListener(MessageCallback that, Local<Value> data) {
7939 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 7918 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
7940 ENTER_V8(isolate); 7919 ENTER_V8(isolate);
7941 i::HandleScope scope(isolate); 7920 i::HandleScope scope(isolate);
7942 i::Handle<i::TemplateList> list = isolate->factory()->message_listeners(); 7921 i::Handle<i::TemplateList> list = isolate->factory()->message_listeners();
7943 NeanderObject obj(isolate, 2); 7922 i::Handle<i::FixedArray> listener = isolate->factory()->NewFixedArray(2);
7944 obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that))); 7923 i::Handle<i::Foreign> foreign =
7945 obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value() 7924 isolate->factory()->NewForeign(FUNCTION_ADDR(that));
7946 : *Utils::OpenHandle(*data)); 7925 listener->set(0, *foreign);
7947 list = i::TemplateList::Add(isolate, list, obj.value()); 7926 listener->set(1, data.IsEmpty() ? isolate->heap()->undefined_value()
7927 : *Utils::OpenHandle(*data));
7928 list = i::TemplateList::Add(isolate, list, listener);
7948 isolate->heap()->SetMessageListeners(*list); 7929 isolate->heap()->SetMessageListeners(*list);
7949 return true; 7930 return true;
7950 } 7931 }
7951 7932
7952 7933
7953 void Isolate::RemoveMessageListeners(MessageCallback that) { 7934 void Isolate::RemoveMessageListeners(MessageCallback that) {
7954 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 7935 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
7955 ENTER_V8(isolate); 7936 ENTER_V8(isolate);
7956 i::HandleScope scope(isolate); 7937 i::HandleScope scope(isolate);
7957 i::DisallowHeapAllocation no_gc; 7938 i::DisallowHeapAllocation no_gc;
7958 i::TemplateList* listeners = isolate->heap()->message_listeners(); 7939 i::TemplateList* listeners = isolate->heap()->message_listeners();
7959 for (int i = 0; i < listeners->length(); i++) { 7940 for (int i = 0; i < listeners->length(); i++) {
7960 if (listeners->get(i)->IsUndefined(isolate)) continue; // skip deleted ones 7941 if (listeners->get(i)->IsUndefined(isolate)) continue; // skip deleted ones
7961 7942 i::FixedArray* listener = i::FixedArray::cast(listeners->get(i));
7962 NeanderObject listener(i::JSObject::cast(listeners->get(i))); 7943 i::Foreign* callback_obj = i::Foreign::cast(listener->get(0));
7963 i::Foreign* callback_obj = i::Foreign::cast(listener.get(0));
7964 if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) { 7944 if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) {
7965 listeners->set(i, isolate->heap()->undefined_value()); 7945 listeners->set(i, isolate->heap()->undefined_value());
7966 } 7946 }
7967 } 7947 }
7968 } 7948 }
7969 7949
7970 7950
7971 void Isolate::SetFailedAccessCheckCallbackFunction( 7951 void Isolate::SetFailedAccessCheckCallbackFunction(
7972 FailedAccessCheckCallback callback) { 7952 FailedAccessCheckCallback callback) {
7973 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 7953 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
8997 Address callback_address = 8977 Address callback_address =
8998 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8978 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8999 VMState<EXTERNAL> state(isolate); 8979 VMState<EXTERNAL> state(isolate);
9000 ExternalCallbackScope call_scope(isolate, callback_address); 8980 ExternalCallbackScope call_scope(isolate, callback_address);
9001 callback(info); 8981 callback(info);
9002 } 8982 }
9003 8983
9004 8984
9005 } // namespace internal 8985 } // namespace internal
9006 } // namespace v8 8986 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/messages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698