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 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 obj->set_name(*Utils::OpenHandle(*name)); | 1218 obj->set_name(*Utils::OpenHandle(*name)); |
1219 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); | 1219 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); |
1220 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); | 1220 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); |
1221 obj->set_property_attributes(static_cast<i::PropertyAttributes>(attributes)); | 1221 obj->set_property_attributes(static_cast<i::PropertyAttributes>(attributes)); |
1222 if (!signature.IsEmpty()) { | 1222 if (!signature.IsEmpty()) { |
1223 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature)); | 1223 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature)); |
1224 } | 1224 } |
1225 return obj; | 1225 return obj; |
1226 } | 1226 } |
1227 | 1227 |
| 1228 namespace { |
| 1229 |
1228 template <typename Getter, typename Setter> | 1230 template <typename Getter, typename Setter> |
1229 static i::Handle<i::AccessorInfo> MakeAccessorInfo( | 1231 i::Handle<i::AccessorInfo> MakeAccessorInfo( |
1230 v8::Local<Name> name, Getter getter, Setter setter, v8::Local<Value> data, | 1232 v8::Local<Name> name, Getter getter, Setter setter, v8::Local<Value> data, |
1231 v8::AccessControl settings, v8::PropertyAttribute attributes, | 1233 v8::AccessControl settings, v8::PropertyAttribute attributes, |
1232 v8::Local<AccessorSignature> signature, bool is_special_data_property) { | 1234 v8::Local<AccessorSignature> signature, bool is_special_data_property) { |
1233 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate(); | 1235 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate(); |
1234 i::Handle<i::AccessorInfo> obj = isolate->factory()->NewAccessorInfo(); | 1236 i::Handle<i::AccessorInfo> obj = isolate->factory()->NewAccessorInfo(); |
1235 SET_FIELD_WRAPPED(obj, set_getter, getter); | 1237 SET_FIELD_WRAPPED(obj, set_getter, getter); |
1236 if (is_special_data_property && setter == nullptr) { | 1238 if (is_special_data_property && setter == nullptr) { |
1237 setter = reinterpret_cast<Setter>(&i::Accessors::ReconfigureToDataProperty); | 1239 setter = reinterpret_cast<Setter>(&i::Accessors::ReconfigureToDataProperty); |
1238 } | 1240 } |
1239 SET_FIELD_WRAPPED(obj, set_setter, setter); | 1241 SET_FIELD_WRAPPED(obj, set_setter, setter); |
| 1242 #ifdef USE_SIMULATOR |
| 1243 i::Address redirected = obj->redirected_getter(); |
| 1244 if (redirected != nullptr) SET_FIELD_WRAPPED(obj, set_js_getter, redirected); |
| 1245 #endif |
1240 if (data.IsEmpty()) { | 1246 if (data.IsEmpty()) { |
1241 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1247 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
1242 } | 1248 } |
1243 obj->set_data(*Utils::OpenHandle(*data)); | 1249 obj->set_data(*Utils::OpenHandle(*data)); |
1244 obj->set_is_special_data_property(is_special_data_property); | 1250 obj->set_is_special_data_property(is_special_data_property); |
1245 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); | 1251 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); |
1246 } | 1252 } |
1247 | 1253 |
| 1254 } // namespace |
1248 | 1255 |
1249 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { | 1256 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { |
1250 i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this, true); | 1257 i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this, true); |
1251 if (!Utils::ApiCheck(!handle.is_null(), | 1258 if (!Utils::ApiCheck(!handle.is_null(), |
1252 "v8::FunctionTemplate::InstanceTemplate()", | 1259 "v8::FunctionTemplate::InstanceTemplate()", |
1253 "Reading from empty handle")) { | 1260 "Reading from empty handle")) { |
1254 return Local<ObjectTemplate>(); | 1261 return Local<ObjectTemplate>(); |
1255 } | 1262 } |
1256 i::Isolate* isolate = handle->GetIsolate(); | 1263 i::Isolate* isolate = handle->GetIsolate(); |
1257 ENTER_V8(isolate); | 1264 ENTER_V8(isolate); |
(...skipping 7530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8788 Address callback_address = | 8795 Address callback_address = |
8789 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8796 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8790 VMState<EXTERNAL> state(isolate); | 8797 VMState<EXTERNAL> state(isolate); |
8791 ExternalCallbackScope call_scope(isolate, callback_address); | 8798 ExternalCallbackScope call_scope(isolate, callback_address); |
8792 callback(info); | 8799 callback(info); |
8793 } | 8800 } |
8794 | 8801 |
8795 | 8802 |
8796 } // namespace internal | 8803 } // namespace internal |
8797 } // namespace v8 | 8804 } // namespace v8 |
OLD | NEW |