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

Side by Side Diff: src/api.cc

Issue 2637873002: Annotate template and factory methods as not executing script (Closed)
Patch Set: updates Created 3 years, 11 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 | « no previous file | no next file » | 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 true) 144 true)
145 145
146 #define PREPARE_FOR_EXECUTION_PRIMITIVE(context, class_name, function_name, T) \ 146 #define PREPARE_FOR_EXECUTION_PRIMITIVE(context, class_name, function_name, T) \
147 PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \ 147 PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \
148 Nothing<T>(), i::HandleScope, false) 148 Nothing<T>(), i::HandleScope, false)
149 149
150 #define PREPARE_FOR_EXECUTION_BOOL(context, class_name, function_name) \ 150 #define PREPARE_FOR_EXECUTION_BOOL(context, class_name, function_name) \
151 PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \ 151 PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \
152 false, i::HandleScope, false) 152 false, i::HandleScope, false)
153 153
154 #ifdef DEBUG
155 #define ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate) \
156 i::VMState<v8::OTHER> __state__((isolate)); \
157 i::DisallowJavascriptExecutionDebugOnly __no_script__((isolate)); \
158 i::DisallowExceptions __no_exceptions__((isolate))
159
154 #define ENTER_V8_FOR_NEW_CONTEXT(isolate) \ 160 #define ENTER_V8_FOR_NEW_CONTEXT(isolate) \
155 i::VMState<v8::OTHER> __state__((isolate)); \ 161 i::VMState<v8::OTHER> __state__((isolate)); \
156 i::DisallowExceptions __no_exceptions__((isolate)) 162 i::DisallowExceptions __no_exceptions__((isolate))
163 #else
164 #define ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate) \
165 i::VMState<v8::OTHER> __state__((isolate));
166
167 #define ENTER_V8_FOR_NEW_CONTEXT(isolate) \
168 i::VMState<v8::OTHER> __state__((isolate));
169 #endif // DEBUG
157 170
158 #define EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, value) \ 171 #define EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, value) \
159 do { \ 172 do { \
160 if (has_pending_exception) { \ 173 if (has_pending_exception) { \
161 call_depth_scope.Escape(); \ 174 call_depth_scope.Escape(); \
162 return value; \ 175 return value; \
163 } \ 176 } \
164 } while (false) 177 } while (false)
165 178
166 179
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 V8_NORETURN void* SealHandleScope::operator new(size_t) { 1071 V8_NORETURN void* SealHandleScope::operator new(size_t) {
1059 base::OS::Abort(); 1072 base::OS::Abort();
1060 abort(); 1073 abort();
1061 } 1074 }
1062 1075
1063 void SealHandleScope::operator delete(void*, size_t) { base::OS::Abort(); } 1076 void SealHandleScope::operator delete(void*, size_t) { base::OS::Abort(); }
1064 1077
1065 void Context::Enter() { 1078 void Context::Enter() {
1066 i::Handle<i::Context> env = Utils::OpenHandle(this); 1079 i::Handle<i::Context> env = Utils::OpenHandle(this);
1067 i::Isolate* isolate = env->GetIsolate(); 1080 i::Isolate* isolate = env->GetIsolate();
1068 ENTER_V8(isolate); 1081 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1069 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer(); 1082 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer();
1070 impl->EnterContext(env); 1083 impl->EnterContext(env);
1071 impl->SaveContext(isolate->context()); 1084 impl->SaveContext(isolate->context());
1072 isolate->set_context(*env); 1085 isolate->set_context(*env);
1073 } 1086 }
1074 1087
1075 1088
1076 void Context::Exit() { 1089 void Context::Exit() {
1077 i::Handle<i::Context> env = Utils::OpenHandle(this); 1090 i::Handle<i::Context> env = Utils::OpenHandle(this);
1078 i::Isolate* isolate = env->GetIsolate(); 1091 i::Isolate* isolate = env->GetIsolate();
1079 ENTER_V8(isolate); 1092 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1080 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer(); 1093 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer();
1081 if (!Utils::ApiCheck(impl->LastEnteredContextWas(env), 1094 if (!Utils::ApiCheck(impl->LastEnteredContextWas(env),
1082 "v8::Context::Exit()", 1095 "v8::Context::Exit()",
1083 "Cannot exit non-entered context")) { 1096 "Cannot exit non-entered context")) {
1084 return; 1097 return;
1085 } 1098 }
1086 impl->LeaveContext(); 1099 impl->LeaveContext();
1087 isolate->set_context(impl->RestoreContext()); 1100 isolate->set_context(impl->RestoreContext());
1088 } 1101 }
1089 1102
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) { 1181 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) {
1169 that->set_number_of_properties(0); 1182 that->set_number_of_properties(0);
1170 that->set_tag(i::Smi::FromInt(type)); 1183 that->set_tag(i::Smi::FromInt(type));
1171 } 1184 }
1172 1185
1173 1186
1174 void Template::Set(v8::Local<Name> name, v8::Local<Data> value, 1187 void Template::Set(v8::Local<Name> name, v8::Local<Data> value,
1175 v8::PropertyAttribute attribute) { 1188 v8::PropertyAttribute attribute) {
1176 auto templ = Utils::OpenHandle(this); 1189 auto templ = Utils::OpenHandle(this);
1177 i::Isolate* isolate = templ->GetIsolate(); 1190 i::Isolate* isolate = templ->GetIsolate();
1178 ENTER_V8(isolate); 1191 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1179 i::HandleScope scope(isolate); 1192 i::HandleScope scope(isolate);
1180 auto value_obj = Utils::OpenHandle(*value); 1193 auto value_obj = Utils::OpenHandle(*value);
1181 CHECK(!value_obj->IsJSReceiver() || value_obj->IsTemplateInfo()); 1194 CHECK(!value_obj->IsJSReceiver() || value_obj->IsTemplateInfo());
1182 if (value_obj->IsObjectTemplateInfo()) { 1195 if (value_obj->IsObjectTemplateInfo()) {
1183 templ->set_serial_number(i::Smi::kZero); 1196 templ->set_serial_number(i::Smi::kZero);
1184 if (templ->IsFunctionTemplateInfo()) { 1197 if (templ->IsFunctionTemplateInfo()) {
1185 i::Handle<i::FunctionTemplateInfo>::cast(templ)->set_do_not_cache(true); 1198 i::Handle<i::FunctionTemplateInfo>::cast(templ)->set_do_not_cache(true);
1186 } 1199 }
1187 } 1200 }
1188 i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name), 1201 i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name),
(...skipping 10 matching lines...) Expand all
1199 void Template::SetAccessorProperty( 1212 void Template::SetAccessorProperty(
1200 v8::Local<v8::Name> name, 1213 v8::Local<v8::Name> name,
1201 v8::Local<FunctionTemplate> getter, 1214 v8::Local<FunctionTemplate> getter,
1202 v8::Local<FunctionTemplate> setter, 1215 v8::Local<FunctionTemplate> setter,
1203 v8::PropertyAttribute attribute, 1216 v8::PropertyAttribute attribute,
1204 v8::AccessControl access_control) { 1217 v8::AccessControl access_control) {
1205 // TODO(verwaest): Remove |access_control|. 1218 // TODO(verwaest): Remove |access_control|.
1206 DCHECK_EQ(v8::DEFAULT, access_control); 1219 DCHECK_EQ(v8::DEFAULT, access_control);
1207 auto templ = Utils::OpenHandle(this); 1220 auto templ = Utils::OpenHandle(this);
1208 auto isolate = templ->GetIsolate(); 1221 auto isolate = templ->GetIsolate();
1209 ENTER_V8(isolate); 1222 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1210 DCHECK(!name.IsEmpty()); 1223 DCHECK(!name.IsEmpty());
1211 DCHECK(!getter.IsEmpty() || !setter.IsEmpty()); 1224 DCHECK(!getter.IsEmpty() || !setter.IsEmpty());
1212 i::HandleScope scope(isolate); 1225 i::HandleScope scope(isolate);
1213 i::ApiNatives::AddAccessorProperty( 1226 i::ApiNatives::AddAccessorProperty(
1214 isolate, templ, Utils::OpenHandle(*name), 1227 isolate, templ, Utils::OpenHandle(*name),
1215 Utils::OpenHandle(*getter, true), Utils::OpenHandle(*setter, true), 1228 Utils::OpenHandle(*getter, true), Utils::OpenHandle(*setter, true),
1216 static_cast<i::PropertyAttributes>(attribute)); 1229 static_cast<i::PropertyAttributes>(attribute));
1217 } 1230 }
1218 1231
1219 1232
1220 // --- F u n c t i o n T e m p l a t e --- 1233 // --- F u n c t i o n T e m p l a t e ---
1221 static void InitializeFunctionTemplate( 1234 static void InitializeFunctionTemplate(
1222 i::Handle<i::FunctionTemplateInfo> info) { 1235 i::Handle<i::FunctionTemplateInfo> info) {
1223 InitializeTemplate(info, Consts::FUNCTION_TEMPLATE); 1236 InitializeTemplate(info, Consts::FUNCTION_TEMPLATE);
1224 info->set_flag(0); 1237 info->set_flag(0);
1225 } 1238 }
1226 1239
1227 static Local<ObjectTemplate> ObjectTemplateNew( 1240 static Local<ObjectTemplate> ObjectTemplateNew(
1228 i::Isolate* isolate, v8::Local<FunctionTemplate> constructor, 1241 i::Isolate* isolate, v8::Local<FunctionTemplate> constructor,
1229 bool do_not_cache); 1242 bool do_not_cache);
1230 1243
1231 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { 1244 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() {
1232 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); 1245 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate();
1233 ENTER_V8(i_isolate); 1246 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
1234 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template(), 1247 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template(),
1235 i_isolate); 1248 i_isolate);
1236 if (result->IsUndefined(i_isolate)) { 1249 if (result->IsUndefined(i_isolate)) {
1237 // Do not cache prototype objects. 1250 // Do not cache prototype objects.
1238 result = Utils::OpenHandle( 1251 result = Utils::OpenHandle(
1239 *ObjectTemplateNew(i_isolate, Local<FunctionTemplate>(), true)); 1252 *ObjectTemplateNew(i_isolate, Local<FunctionTemplate>(), true));
1240 Utils::OpenHandle(this)->set_prototype_template(*result); 1253 Utils::OpenHandle(this)->set_prototype_template(*result);
1241 } 1254 }
1242 return ToApiHandle<ObjectTemplate>(result); 1255 return ToApiHandle<ObjectTemplate>(result);
1243 } 1256 }
1244 1257
1245 void FunctionTemplate::SetPrototypeProviderTemplate( 1258 void FunctionTemplate::SetPrototypeProviderTemplate(
1246 Local<FunctionTemplate> prototype_provider) { 1259 Local<FunctionTemplate> prototype_provider) {
1247 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); 1260 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate();
1248 ENTER_V8(i_isolate); 1261 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
1249 i::Handle<i::Object> result = Utils::OpenHandle(*prototype_provider); 1262 i::Handle<i::Object> result = Utils::OpenHandle(*prototype_provider);
1250 auto info = Utils::OpenHandle(this); 1263 auto info = Utils::OpenHandle(this);
1251 CHECK(info->prototype_template()->IsUndefined(i_isolate)); 1264 CHECK(info->prototype_template()->IsUndefined(i_isolate));
1252 CHECK(info->parent_template()->IsUndefined(i_isolate)); 1265 CHECK(info->parent_template()->IsUndefined(i_isolate));
1253 info->set_prototype_provider_template(*result); 1266 info->set_prototype_provider_template(*result);
1254 } 1267 }
1255 1268
1256 static void EnsureNotInstantiated(i::Handle<i::FunctionTemplateInfo> info, 1269 static void EnsureNotInstantiated(i::Handle<i::FunctionTemplateInfo> info,
1257 const char* func) { 1270 const char* func) {
1258 Utils::ApiCheck(!info->instantiated(), func, 1271 Utils::ApiCheck(!info->instantiated(), func,
1259 "FunctionTemplate already instantiated"); 1272 "FunctionTemplate already instantiated");
1260 } 1273 }
1261 1274
1262 1275
1263 void FunctionTemplate::Inherit(v8::Local<FunctionTemplate> value) { 1276 void FunctionTemplate::Inherit(v8::Local<FunctionTemplate> value) {
1264 auto info = Utils::OpenHandle(this); 1277 auto info = Utils::OpenHandle(this);
1265 EnsureNotInstantiated(info, "v8::FunctionTemplate::Inherit"); 1278 EnsureNotInstantiated(info, "v8::FunctionTemplate::Inherit");
1266 i::Isolate* i_isolate = info->GetIsolate(); 1279 i::Isolate* i_isolate = info->GetIsolate();
1267 ENTER_V8(i_isolate); 1280 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
1268 CHECK(info->prototype_provider_template()->IsUndefined(i_isolate)); 1281 CHECK(info->prototype_provider_template()->IsUndefined(i_isolate));
1269 info->set_parent_template(*Utils::OpenHandle(*value)); 1282 info->set_parent_template(*Utils::OpenHandle(*value));
1270 } 1283 }
1271 1284
1272 static Local<FunctionTemplate> FunctionTemplateNew( 1285 static Local<FunctionTemplate> FunctionTemplateNew(
1273 i::Isolate* isolate, FunctionCallback callback, 1286 i::Isolate* isolate, FunctionCallback callback,
1274 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data, 1287 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data,
1275 v8::Local<Signature> signature, int length, bool do_not_cache, 1288 v8::Local<Signature> signature, int length, bool do_not_cache,
1276 v8::Local<Private> cached_property_name = v8::Local<Private>()) { 1289 v8::Local<Private> cached_property_name = v8::Local<Private>()) {
1277 i::Handle<i::Struct> struct_obj = 1290 i::Handle<i::Struct> struct_obj =
(...skipping 26 matching lines...) Expand all
1304 return Utils::ToLocal(obj); 1317 return Utils::ToLocal(obj);
1305 } 1318 }
1306 1319
1307 Local<FunctionTemplate> FunctionTemplate::New( 1320 Local<FunctionTemplate> FunctionTemplate::New(
1308 Isolate* isolate, FunctionCallback callback, v8::Local<Value> data, 1321 Isolate* isolate, FunctionCallback callback, v8::Local<Value> data,
1309 v8::Local<Signature> signature, int length, ConstructorBehavior behavior) { 1322 v8::Local<Signature> signature, int length, ConstructorBehavior behavior) {
1310 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 1323 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
1311 // Changes to the environment cannot be captured in the snapshot. Expect no 1324 // Changes to the environment cannot be captured in the snapshot. Expect no
1312 // function templates when the isolate is created for serialization. 1325 // function templates when the isolate is created for serialization.
1313 LOG_API(i_isolate, FunctionTemplate, New); 1326 LOG_API(i_isolate, FunctionTemplate, New);
1314 ENTER_V8(i_isolate); 1327 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
1315 auto templ = FunctionTemplateNew(i_isolate, callback, nullptr, data, 1328 auto templ = FunctionTemplateNew(i_isolate, callback, nullptr, data,
1316 signature, length, false); 1329 signature, length, false);
1317 if (behavior == ConstructorBehavior::kThrow) templ->RemovePrototype(); 1330 if (behavior == ConstructorBehavior::kThrow) templ->RemovePrototype();
1318 return templ; 1331 return templ;
1319 } 1332 }
1320 1333
1321 MaybeLocal<FunctionTemplate> FunctionTemplate::FromSnapshot(Isolate* isolate, 1334 MaybeLocal<FunctionTemplate> FunctionTemplate::FromSnapshot(Isolate* isolate,
1322 size_t index) { 1335 size_t index) {
1323 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 1336 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
1324 i::FixedArray* templates = i_isolate->heap()->serialized_templates(); 1337 i::FixedArray* templates = i_isolate->heap()->serialized_templates();
1325 int int_index = static_cast<int>(index); 1338 int int_index = static_cast<int>(index);
1326 if (int_index < templates->length()) { 1339 if (int_index < templates->length()) {
1327 i::Object* info = templates->get(int_index); 1340 i::Object* info = templates->get(int_index);
1328 if (info->IsFunctionTemplateInfo()) { 1341 if (info->IsFunctionTemplateInfo()) {
1329 return Utils::ToLocal(i::Handle<i::FunctionTemplateInfo>( 1342 return Utils::ToLocal(i::Handle<i::FunctionTemplateInfo>(
1330 i::FunctionTemplateInfo::cast(info))); 1343 i::FunctionTemplateInfo::cast(info)));
1331 } 1344 }
1332 } 1345 }
1333 return Local<FunctionTemplate>(); 1346 return Local<FunctionTemplate>();
1334 } 1347 }
1335 1348
1336 Local<FunctionTemplate> FunctionTemplate::NewWithFastHandler( 1349 Local<FunctionTemplate> FunctionTemplate::NewWithFastHandler(
1337 Isolate* isolate, FunctionCallback callback, 1350 Isolate* isolate, FunctionCallback callback,
1338 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data, 1351 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data,
1339 v8::Local<Signature> signature, int length) { 1352 v8::Local<Signature> signature, int length) {
1340 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 1353 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
1341 LOG_API(i_isolate, FunctionTemplate, NewWithFastHandler); 1354 LOG_API(i_isolate, FunctionTemplate, NewWithFastHandler);
1342 ENTER_V8(i_isolate); 1355 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
1343 return FunctionTemplateNew(i_isolate, callback, fast_handler, data, signature, 1356 return FunctionTemplateNew(i_isolate, callback, fast_handler, data, signature,
1344 length, false); 1357 length, false);
1345 } 1358 }
1346 1359
1347 Local<FunctionTemplate> FunctionTemplate::NewWithCache( 1360 Local<FunctionTemplate> FunctionTemplate::NewWithCache(
1348 Isolate* isolate, FunctionCallback callback, Local<Private> cache_property, 1361 Isolate* isolate, FunctionCallback callback, Local<Private> cache_property,
1349 Local<Value> data, Local<Signature> signature, int length) { 1362 Local<Value> data, Local<Signature> signature, int length) {
1350 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 1363 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
1351 LOG_API(i_isolate, FunctionTemplate, NewWithCache); 1364 LOG_API(i_isolate, FunctionTemplate, NewWithCache);
1352 ENTER_V8(i_isolate); 1365 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
1353 return FunctionTemplateNew(i_isolate, callback, nullptr, data, signature, 1366 return FunctionTemplateNew(i_isolate, callback, nullptr, data, signature,
1354 length, false, cache_property); 1367 length, false, cache_property);
1355 } 1368 }
1356 1369
1357 Local<Signature> Signature::New(Isolate* isolate, 1370 Local<Signature> Signature::New(Isolate* isolate,
1358 Local<FunctionTemplate> receiver) { 1371 Local<FunctionTemplate> receiver) {
1359 return Utils::SignatureToLocal(Utils::OpenHandle(*receiver)); 1372 return Utils::SignatureToLocal(Utils::OpenHandle(*receiver));
1360 } 1373 }
1361 1374
1362 1375
1363 Local<AccessorSignature> AccessorSignature::New( 1376 Local<AccessorSignature> AccessorSignature::New(
1364 Isolate* isolate, Local<FunctionTemplate> receiver) { 1377 Isolate* isolate, Local<FunctionTemplate> receiver) {
1365 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); 1378 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver));
1366 } 1379 }
1367 1380
1368 1381
1369 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \ 1382 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \
1370 i::Handle<i::Object> foreign = FromCData(obj->GetIsolate(), cdata); \ 1383 i::Handle<i::Object> foreign = FromCData(obj->GetIsolate(), cdata); \
1371 (obj)->setter(*foreign); \ 1384 (obj)->setter(*foreign); \
1372 } while (false) 1385 } while (false)
1373 1386
1374 1387
1375 void FunctionTemplate::SetCallHandler( 1388 void FunctionTemplate::SetCallHandler(
1376 FunctionCallback callback, v8::Local<Value> data, 1389 FunctionCallback callback, v8::Local<Value> data,
1377 experimental::FastAccessorBuilder* fast_handler) { 1390 experimental::FastAccessorBuilder* fast_handler) {
1378 auto info = Utils::OpenHandle(this); 1391 auto info = Utils::OpenHandle(this);
1379 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetCallHandler"); 1392 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetCallHandler");
1380 i::Isolate* isolate = info->GetIsolate(); 1393 i::Isolate* isolate = info->GetIsolate();
1381 ENTER_V8(isolate); 1394 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1382 i::HandleScope scope(isolate); 1395 i::HandleScope scope(isolate);
1383 i::Handle<i::Struct> struct_obj = 1396 i::Handle<i::Struct> struct_obj =
1384 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); 1397 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE);
1385 i::Handle<i::CallHandlerInfo> obj = 1398 i::Handle<i::CallHandlerInfo> obj =
1386 i::Handle<i::CallHandlerInfo>::cast(struct_obj); 1399 i::Handle<i::CallHandlerInfo>::cast(struct_obj);
1387 SET_FIELD_WRAPPED(obj, set_callback, callback); 1400 SET_FIELD_WRAPPED(obj, set_callback, callback);
1388 i::MaybeHandle<i::Code> code = 1401 i::MaybeHandle<i::Code> code =
1389 i::experimental::BuildCodeFromFastAccessorBuilder(fast_handler); 1402 i::experimental::BuildCodeFromFastAccessorBuilder(fast_handler);
1390 if (!code.is_null()) { 1403 if (!code.is_null()) {
1391 obj->set_fast_handler(*code.ToHandleChecked()); 1404 obj->set_fast_handler(*code.ToHandleChecked());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 } // namespace 1456 } // namespace
1444 1457
1445 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { 1458 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() {
1446 i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this, true); 1459 i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this, true);
1447 if (!Utils::ApiCheck(!handle.is_null(), 1460 if (!Utils::ApiCheck(!handle.is_null(),
1448 "v8::FunctionTemplate::InstanceTemplate()", 1461 "v8::FunctionTemplate::InstanceTemplate()",
1449 "Reading from empty handle")) { 1462 "Reading from empty handle")) {
1450 return Local<ObjectTemplate>(); 1463 return Local<ObjectTemplate>();
1451 } 1464 }
1452 i::Isolate* isolate = handle->GetIsolate(); 1465 i::Isolate* isolate = handle->GetIsolate();
1453 ENTER_V8(isolate); 1466 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1454 if (handle->instance_template()->IsUndefined(isolate)) { 1467 if (handle->instance_template()->IsUndefined(isolate)) {
1455 Local<ObjectTemplate> templ = 1468 Local<ObjectTemplate> templ =
1456 ObjectTemplate::New(isolate, ToApiHandle<FunctionTemplate>(handle)); 1469 ObjectTemplate::New(isolate, ToApiHandle<FunctionTemplate>(handle));
1457 handle->set_instance_template(*Utils::OpenHandle(*templ)); 1470 handle->set_instance_template(*Utils::OpenHandle(*templ));
1458 } 1471 }
1459 i::Handle<i::ObjectTemplateInfo> result( 1472 i::Handle<i::ObjectTemplateInfo> result(
1460 i::ObjectTemplateInfo::cast(handle->instance_template())); 1473 i::ObjectTemplateInfo::cast(handle->instance_template()));
1461 return Utils::ToLocal(result); 1474 return Utils::ToLocal(result);
1462 } 1475 }
1463 1476
1464 1477
1465 void FunctionTemplate::SetLength(int length) { 1478 void FunctionTemplate::SetLength(int length) {
1466 auto info = Utils::OpenHandle(this); 1479 auto info = Utils::OpenHandle(this);
1467 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetLength"); 1480 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetLength");
1468 auto isolate = info->GetIsolate(); 1481 auto isolate = info->GetIsolate();
1469 ENTER_V8(isolate); 1482 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1470 info->set_length(length); 1483 info->set_length(length);
1471 } 1484 }
1472 1485
1473 1486
1474 void FunctionTemplate::SetClassName(Local<String> name) { 1487 void FunctionTemplate::SetClassName(Local<String> name) {
1475 auto info = Utils::OpenHandle(this); 1488 auto info = Utils::OpenHandle(this);
1476 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetClassName"); 1489 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetClassName");
1477 auto isolate = info->GetIsolate(); 1490 auto isolate = info->GetIsolate();
1478 ENTER_V8(isolate); 1491 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1479 info->set_class_name(*Utils::OpenHandle(*name)); 1492 info->set_class_name(*Utils::OpenHandle(*name));
1480 } 1493 }
1481 1494
1482 1495
1483 void FunctionTemplate::SetAcceptAnyReceiver(bool value) { 1496 void FunctionTemplate::SetAcceptAnyReceiver(bool value) {
1484 auto info = Utils::OpenHandle(this); 1497 auto info = Utils::OpenHandle(this);
1485 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetAcceptAnyReceiver"); 1498 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetAcceptAnyReceiver");
1486 auto isolate = info->GetIsolate(); 1499 auto isolate = info->GetIsolate();
1487 ENTER_V8(isolate); 1500 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1488 info->set_accept_any_receiver(value); 1501 info->set_accept_any_receiver(value);
1489 } 1502 }
1490 1503
1491 1504
1492 void FunctionTemplate::SetHiddenPrototype(bool value) { 1505 void FunctionTemplate::SetHiddenPrototype(bool value) {
1493 auto info = Utils::OpenHandle(this); 1506 auto info = Utils::OpenHandle(this);
1494 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetHiddenPrototype"); 1507 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetHiddenPrototype");
1495 auto isolate = info->GetIsolate(); 1508 auto isolate = info->GetIsolate();
1496 ENTER_V8(isolate); 1509 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1497 info->set_hidden_prototype(value); 1510 info->set_hidden_prototype(value);
1498 } 1511 }
1499 1512
1500 1513
1501 void FunctionTemplate::ReadOnlyPrototype() { 1514 void FunctionTemplate::ReadOnlyPrototype() {
1502 auto info = Utils::OpenHandle(this); 1515 auto info = Utils::OpenHandle(this);
1503 EnsureNotInstantiated(info, "v8::FunctionTemplate::ReadOnlyPrototype"); 1516 EnsureNotInstantiated(info, "v8::FunctionTemplate::ReadOnlyPrototype");
1504 auto isolate = info->GetIsolate(); 1517 auto isolate = info->GetIsolate();
1505 ENTER_V8(isolate); 1518 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1506 info->set_read_only_prototype(true); 1519 info->set_read_only_prototype(true);
1507 } 1520 }
1508 1521
1509 1522
1510 void FunctionTemplate::RemovePrototype() { 1523 void FunctionTemplate::RemovePrototype() {
1511 auto info = Utils::OpenHandle(this); 1524 auto info = Utils::OpenHandle(this);
1512 EnsureNotInstantiated(info, "v8::FunctionTemplate::RemovePrototype"); 1525 EnsureNotInstantiated(info, "v8::FunctionTemplate::RemovePrototype");
1513 auto isolate = info->GetIsolate(); 1526 auto isolate = info->GetIsolate();
1514 ENTER_V8(isolate); 1527 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1515 info->set_remove_prototype(true); 1528 info->set_remove_prototype(true);
1516 } 1529 }
1517 1530
1518 1531
1519 // --- O b j e c t T e m p l a t e --- 1532 // --- O b j e c t T e m p l a t e ---
1520 1533
1521 1534
1522 Local<ObjectTemplate> ObjectTemplate::New( 1535 Local<ObjectTemplate> ObjectTemplate::New(
1523 Isolate* isolate, v8::Local<FunctionTemplate> constructor) { 1536 Isolate* isolate, v8::Local<FunctionTemplate> constructor) {
1524 return New(reinterpret_cast<i::Isolate*>(isolate), constructor); 1537 return New(reinterpret_cast<i::Isolate*>(isolate), constructor);
1525 } 1538 }
1526 1539
1527 1540
1528 Local<ObjectTemplate> ObjectTemplate::New() { 1541 Local<ObjectTemplate> ObjectTemplate::New() {
1529 return New(i::Isolate::Current(), Local<FunctionTemplate>()); 1542 return New(i::Isolate::Current(), Local<FunctionTemplate>());
1530 } 1543 }
1531 1544
1532 static Local<ObjectTemplate> ObjectTemplateNew( 1545 static Local<ObjectTemplate> ObjectTemplateNew(
1533 i::Isolate* isolate, v8::Local<FunctionTemplate> constructor, 1546 i::Isolate* isolate, v8::Local<FunctionTemplate> constructor,
1534 bool do_not_cache) { 1547 bool do_not_cache) {
1535 LOG_API(isolate, ObjectTemplate, New); 1548 LOG_API(isolate, ObjectTemplate, New);
1536 ENTER_V8(isolate); 1549 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1537 i::Handle<i::Struct> struct_obj = 1550 i::Handle<i::Struct> struct_obj =
1538 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); 1551 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE);
1539 i::Handle<i::ObjectTemplateInfo> obj = 1552 i::Handle<i::ObjectTemplateInfo> obj =
1540 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); 1553 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj);
1541 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); 1554 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE);
1542 int next_serial_number = 0; 1555 int next_serial_number = 0;
1543 if (!do_not_cache) { 1556 if (!do_not_cache) {
1544 next_serial_number = isolate->heap()->GetNextTemplateSerialNumber(); 1557 next_serial_number = isolate->heap()->GetNextTemplateSerialNumber();
1545 } 1558 }
1546 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); 1559 obj->set_serial_number(i::Smi::FromInt(next_serial_number));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 template <typename Getter, typename Setter, typename Data, typename Template> 1604 template <typename Getter, typename Setter, typename Data, typename Template>
1592 static bool TemplateSetAccessor(Template* template_obj, v8::Local<Name> name, 1605 static bool TemplateSetAccessor(Template* template_obj, v8::Local<Name> name,
1593 Getter getter, Setter setter, Data data, 1606 Getter getter, Setter setter, Data data,
1594 AccessControl settings, 1607 AccessControl settings,
1595 PropertyAttribute attribute, 1608 PropertyAttribute attribute,
1596 v8::Local<AccessorSignature> signature, 1609 v8::Local<AccessorSignature> signature,
1597 bool is_special_data_property, 1610 bool is_special_data_property,
1598 bool replace_on_access) { 1611 bool replace_on_access) {
1599 auto info = Utils::OpenHandle(template_obj); 1612 auto info = Utils::OpenHandle(template_obj);
1600 auto isolate = info->GetIsolate(); 1613 auto isolate = info->GetIsolate();
1601 ENTER_V8(isolate); 1614 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1602 i::HandleScope scope(isolate); 1615 i::HandleScope scope(isolate);
1603 auto obj = 1616 auto obj =
1604 MakeAccessorInfo(name, getter, setter, data, settings, attribute, 1617 MakeAccessorInfo(name, getter, setter, data, settings, attribute,
1605 signature, is_special_data_property, replace_on_access); 1618 signature, is_special_data_property, replace_on_access);
1606 if (obj.is_null()) return false; 1619 if (obj.is_null()) return false;
1607 i::ApiNatives::AddNativeDataProperty(isolate, info, obj); 1620 i::ApiNatives::AddNativeDataProperty(isolate, info, obj);
1608 return true; 1621 return true;
1609 } 1622 }
1610 1623
1611 1624
(...skipping 26 matching lines...) Expand all
1638 PropertyAttribute attribute) { 1651 PropertyAttribute attribute) {
1639 TemplateSetAccessor( 1652 TemplateSetAccessor(
1640 this, name, getter, static_cast<AccessorNameSetterCallback>(nullptr), 1653 this, name, getter, static_cast<AccessorNameSetterCallback>(nullptr),
1641 data, DEFAULT, attribute, Local<AccessorSignature>(), true, true); 1654 data, DEFAULT, attribute, Local<AccessorSignature>(), true, true);
1642 } 1655 }
1643 1656
1644 void Template::SetIntrinsicDataProperty(Local<Name> name, Intrinsic intrinsic, 1657 void Template::SetIntrinsicDataProperty(Local<Name> name, Intrinsic intrinsic,
1645 PropertyAttribute attribute) { 1658 PropertyAttribute attribute) {
1646 auto templ = Utils::OpenHandle(this); 1659 auto templ = Utils::OpenHandle(this);
1647 i::Isolate* isolate = templ->GetIsolate(); 1660 i::Isolate* isolate = templ->GetIsolate();
1648 ENTER_V8(isolate); 1661 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1649 i::HandleScope scope(isolate); 1662 i::HandleScope scope(isolate);
1650 i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name), 1663 i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name),
1651 intrinsic, 1664 intrinsic,
1652 static_cast<i::PropertyAttributes>(attribute)); 1665 static_cast<i::PropertyAttributes>(attribute));
1653 } 1666 }
1654 1667
1655 1668
1656 void ObjectTemplate::SetAccessor(v8::Local<String> name, 1669 void ObjectTemplate::SetAccessor(v8::Local<String> name,
1657 AccessorGetterCallback getter, 1670 AccessorGetterCallback getter,
1658 AccessorSetterCallback setter, 1671 AccessorSetterCallback setter,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 return obj; 1724 return obj;
1712 } 1725 }
1713 1726
1714 template <typename Getter, typename Setter, typename Query, typename Descriptor, 1727 template <typename Getter, typename Setter, typename Query, typename Descriptor,
1715 typename Deleter, typename Enumerator, typename Definer> 1728 typename Deleter, typename Enumerator, typename Definer>
1716 static void ObjectTemplateSetNamedPropertyHandler( 1729 static void ObjectTemplateSetNamedPropertyHandler(
1717 ObjectTemplate* templ, Getter getter, Setter setter, Query query, 1730 ObjectTemplate* templ, Getter getter, Setter setter, Query query,
1718 Descriptor descriptor, Deleter remover, Enumerator enumerator, 1731 Descriptor descriptor, Deleter remover, Enumerator enumerator,
1719 Definer definer, Local<Value> data, PropertyHandlerFlags flags) { 1732 Definer definer, Local<Value> data, PropertyHandlerFlags flags) {
1720 i::Isolate* isolate = Utils::OpenHandle(templ)->GetIsolate(); 1733 i::Isolate* isolate = Utils::OpenHandle(templ)->GetIsolate();
1721 ENTER_V8(isolate); 1734 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1722 i::HandleScope scope(isolate); 1735 i::HandleScope scope(isolate);
1723 auto cons = EnsureConstructor(isolate, templ); 1736 auto cons = EnsureConstructor(isolate, templ);
1724 EnsureNotInstantiated(cons, "ObjectTemplateSetNamedPropertyHandler"); 1737 EnsureNotInstantiated(cons, "ObjectTemplateSetNamedPropertyHandler");
1725 auto obj = CreateInterceptorInfo(isolate, getter, setter, query, descriptor, 1738 auto obj = CreateInterceptorInfo(isolate, getter, setter, query, descriptor,
1726 remover, enumerator, definer, data, flags); 1739 remover, enumerator, definer, data, flags);
1727 cons->set_named_property_handler(*obj); 1740 cons->set_named_property_handler(*obj);
1728 } 1741 }
1729 1742
1730 void ObjectTemplate::SetNamedPropertyHandler( 1743 void ObjectTemplate::SetNamedPropertyHandler(
1731 NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter, 1744 NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter,
1732 NamedPropertyQueryCallback query, NamedPropertyDeleterCallback remover, 1745 NamedPropertyQueryCallback query, NamedPropertyDeleterCallback remover,
1733 NamedPropertyEnumeratorCallback enumerator, Local<Value> data) { 1746 NamedPropertyEnumeratorCallback enumerator, Local<Value> data) {
1734 ObjectTemplateSetNamedPropertyHandler( 1747 ObjectTemplateSetNamedPropertyHandler(
1735 this, getter, setter, query, nullptr, remover, enumerator, nullptr, data, 1748 this, getter, setter, query, nullptr, remover, enumerator, nullptr, data,
1736 PropertyHandlerFlags::kOnlyInterceptStrings); 1749 PropertyHandlerFlags::kOnlyInterceptStrings);
1737 } 1750 }
1738 1751
1739 void ObjectTemplate::SetHandler( 1752 void ObjectTemplate::SetHandler(
1740 const NamedPropertyHandlerConfiguration& config) { 1753 const NamedPropertyHandlerConfiguration& config) {
1741 ObjectTemplateSetNamedPropertyHandler( 1754 ObjectTemplateSetNamedPropertyHandler(
1742 this, config.getter, config.setter, config.query, config.descriptor, 1755 this, config.getter, config.setter, config.query, config.descriptor,
1743 config.deleter, config.enumerator, config.definer, config.data, 1756 config.deleter, config.enumerator, config.definer, config.data,
1744 config.flags); 1757 config.flags);
1745 } 1758 }
1746 1759
1747 1760
1748 void ObjectTemplate::MarkAsUndetectable() { 1761 void ObjectTemplate::MarkAsUndetectable() {
1749 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1762 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1750 ENTER_V8(isolate); 1763 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1751 i::HandleScope scope(isolate); 1764 i::HandleScope scope(isolate);
1752 auto cons = EnsureConstructor(isolate, this); 1765 auto cons = EnsureConstructor(isolate, this);
1753 EnsureNotInstantiated(cons, "v8::ObjectTemplate::MarkAsUndetectable"); 1766 EnsureNotInstantiated(cons, "v8::ObjectTemplate::MarkAsUndetectable");
1754 cons->set_undetectable(true); 1767 cons->set_undetectable(true);
1755 } 1768 }
1756 1769
1757 1770
1758 void ObjectTemplate::SetAccessCheckCallback(AccessCheckCallback callback, 1771 void ObjectTemplate::SetAccessCheckCallback(AccessCheckCallback callback,
1759 Local<Value> data) { 1772 Local<Value> data) {
1760 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1773 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1761 ENTER_V8(isolate); 1774 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1762 i::HandleScope scope(isolate); 1775 i::HandleScope scope(isolate);
1763 auto cons = EnsureConstructor(isolate, this); 1776 auto cons = EnsureConstructor(isolate, this);
1764 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetAccessCheckCallback"); 1777 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetAccessCheckCallback");
1765 1778
1766 i::Handle<i::Struct> struct_info = 1779 i::Handle<i::Struct> struct_info =
1767 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); 1780 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE);
1768 i::Handle<i::AccessCheckInfo> info = 1781 i::Handle<i::AccessCheckInfo> info =
1769 i::Handle<i::AccessCheckInfo>::cast(struct_info); 1782 i::Handle<i::AccessCheckInfo>::cast(struct_info);
1770 1783
1771 SET_FIELD_WRAPPED(info, set_callback, callback); 1784 SET_FIELD_WRAPPED(info, set_callback, callback);
1772 info->set_named_interceptor(nullptr); 1785 info->set_named_interceptor(nullptr);
1773 info->set_indexed_interceptor(nullptr); 1786 info->set_indexed_interceptor(nullptr);
1774 1787
1775 if (data.IsEmpty()) { 1788 if (data.IsEmpty()) {
1776 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); 1789 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1777 } 1790 }
1778 info->set_data(*Utils::OpenHandle(*data)); 1791 info->set_data(*Utils::OpenHandle(*data));
1779 1792
1780 cons->set_access_check_info(*info); 1793 cons->set_access_check_info(*info);
1781 cons->set_needs_access_check(true); 1794 cons->set_needs_access_check(true);
1782 } 1795 }
1783 1796
1784 void ObjectTemplate::SetAccessCheckCallbackAndHandler( 1797 void ObjectTemplate::SetAccessCheckCallbackAndHandler(
1785 AccessCheckCallback callback, 1798 AccessCheckCallback callback,
1786 const NamedPropertyHandlerConfiguration& named_handler, 1799 const NamedPropertyHandlerConfiguration& named_handler,
1787 const IndexedPropertyHandlerConfiguration& indexed_handler, 1800 const IndexedPropertyHandlerConfiguration& indexed_handler,
1788 Local<Value> data) { 1801 Local<Value> data) {
1789 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1802 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1790 ENTER_V8(isolate); 1803 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1791 i::HandleScope scope(isolate); 1804 i::HandleScope scope(isolate);
1792 auto cons = EnsureConstructor(isolate, this); 1805 auto cons = EnsureConstructor(isolate, this);
1793 EnsureNotInstantiated( 1806 EnsureNotInstantiated(
1794 cons, "v8::ObjectTemplate::SetAccessCheckCallbackWithHandler"); 1807 cons, "v8::ObjectTemplate::SetAccessCheckCallbackWithHandler");
1795 1808
1796 i::Handle<i::Struct> struct_info = 1809 i::Handle<i::Struct> struct_info =
1797 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); 1810 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE);
1798 i::Handle<i::AccessCheckInfo> info = 1811 i::Handle<i::AccessCheckInfo> info =
1799 i::Handle<i::AccessCheckInfo>::cast(struct_info); 1812 i::Handle<i::AccessCheckInfo>::cast(struct_info);
1800 1813
(...skipping 15 matching lines...) Expand all
1816 } 1829 }
1817 info->set_data(*Utils::OpenHandle(*data)); 1830 info->set_data(*Utils::OpenHandle(*data));
1818 1831
1819 cons->set_access_check_info(*info); 1832 cons->set_access_check_info(*info);
1820 cons->set_needs_access_check(true); 1833 cons->set_needs_access_check(true);
1821 } 1834 }
1822 1835
1823 void ObjectTemplate::SetHandler( 1836 void ObjectTemplate::SetHandler(
1824 const IndexedPropertyHandlerConfiguration& config) { 1837 const IndexedPropertyHandlerConfiguration& config) {
1825 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1838 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1826 ENTER_V8(isolate); 1839 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1827 i::HandleScope scope(isolate); 1840 i::HandleScope scope(isolate);
1828 auto cons = EnsureConstructor(isolate, this); 1841 auto cons = EnsureConstructor(isolate, this);
1829 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetHandler"); 1842 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetHandler");
1830 auto obj = CreateInterceptorInfo(isolate, config.getter, config.setter, 1843 auto obj = CreateInterceptorInfo(isolate, config.getter, config.setter,
1831 config.query, config.descriptor, 1844 config.query, config.descriptor,
1832 config.deleter, config.enumerator, 1845 config.deleter, config.enumerator,
1833 config.definer, config.data, config.flags); 1846 config.definer, config.data, config.flags);
1834 cons->set_indexed_property_handler(*obj); 1847 cons->set_indexed_property_handler(*obj);
1835 } 1848 }
1836 1849
1837 1850
1838 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback, 1851 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback,
1839 Local<Value> data) { 1852 Local<Value> data) {
1840 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1853 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1841 ENTER_V8(isolate); 1854 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1842 i::HandleScope scope(isolate); 1855 i::HandleScope scope(isolate);
1843 auto cons = EnsureConstructor(isolate, this); 1856 auto cons = EnsureConstructor(isolate, this);
1844 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetCallAsFunctionHandler"); 1857 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetCallAsFunctionHandler");
1845 i::Handle<i::Struct> struct_obj = 1858 i::Handle<i::Struct> struct_obj =
1846 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); 1859 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE);
1847 i::Handle<i::CallHandlerInfo> obj = 1860 i::Handle<i::CallHandlerInfo> obj =
1848 i::Handle<i::CallHandlerInfo>::cast(struct_obj); 1861 i::Handle<i::CallHandlerInfo>::cast(struct_obj);
1849 SET_FIELD_WRAPPED(obj, set_callback, callback); 1862 SET_FIELD_WRAPPED(obj, set_callback, callback);
1850 if (data.IsEmpty()) { 1863 if (data.IsEmpty()) {
1851 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); 1864 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1852 } 1865 }
1853 obj->set_data(*Utils::OpenHandle(*data)); 1866 obj->set_data(*Utils::OpenHandle(*data));
1854 cons->set_instance_call_handler(*obj); 1867 cons->set_instance_call_handler(*obj);
1855 } 1868 }
1856 1869
1857 1870
1858 int ObjectTemplate::InternalFieldCount() { 1871 int ObjectTemplate::InternalFieldCount() {
1859 return Utils::OpenHandle(this)->internal_field_count(); 1872 return Utils::OpenHandle(this)->internal_field_count();
1860 } 1873 }
1861 1874
1862 1875
1863 void ObjectTemplate::SetInternalFieldCount(int value) { 1876 void ObjectTemplate::SetInternalFieldCount(int value) {
1864 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1877 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1865 if (!Utils::ApiCheck(i::Smi::IsValid(value), 1878 if (!Utils::ApiCheck(i::Smi::IsValid(value),
1866 "v8::ObjectTemplate::SetInternalFieldCount()", 1879 "v8::ObjectTemplate::SetInternalFieldCount()",
1867 "Invalid internal field count")) { 1880 "Invalid internal field count")) {
1868 return; 1881 return;
1869 } 1882 }
1870 ENTER_V8(isolate); 1883 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1871 if (value > 0) { 1884 if (value > 0) {
1872 // The internal field count is set by the constructor function's 1885 // The internal field count is set by the constructor function's
1873 // construct code, so we ensure that there is a constructor 1886 // construct code, so we ensure that there is a constructor
1874 // function to do the setting. 1887 // function to do the setting.
1875 EnsureConstructor(isolate, this); 1888 EnsureConstructor(isolate, this);
1876 } 1889 }
1877 Utils::OpenHandle(this)->set_internal_field_count(value); 1890 Utils::OpenHandle(this)->set_internal_field_count(value);
1878 } 1891 }
1879 1892
1880 bool ObjectTemplate::IsImmutableProto() { 1893 bool ObjectTemplate::IsImmutableProto() {
1881 return Utils::OpenHandle(this)->immutable_proto(); 1894 return Utils::OpenHandle(this)->immutable_proto();
1882 } 1895 }
1883 1896
1884 void ObjectTemplate::SetImmutableProto() { 1897 void ObjectTemplate::SetImmutableProto() {
1885 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1898 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1886 ENTER_V8(isolate); 1899 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
1887 Utils::OpenHandle(this)->set_immutable_proto(true); 1900 Utils::OpenHandle(this)->set_immutable_proto(true);
1888 } 1901 }
1889 1902
1890 // --- S c r i p t s --- 1903 // --- S c r i p t s ---
1891 1904
1892 1905
1893 // Internally, UnboundScript is a SharedFunctionInfo, and Script is a 1906 // Internally, UnboundScript is a SharedFunctionInfo, and Script is a
1894 // JSFunction. 1907 // JSFunction.
1895 1908
1896 ScriptCompiler::CachedData::CachedData(const uint8_t* data_, int length_, 1909 ScriptCompiler::CachedData::CachedData(const uint8_t* data_, int length_,
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
2911 2924
2912 bool StackFrame::IsConstructor() const { 2925 bool StackFrame::IsConstructor() const {
2913 return getBoolProperty(this, "isConstructor"); 2926 return getBoolProperty(this, "isConstructor");
2914 } 2927 }
2915 2928
2916 2929
2917 // --- N a t i v e W e a k M a p --- 2930 // --- N a t i v e W e a k M a p ---
2918 2931
2919 Local<NativeWeakMap> NativeWeakMap::New(Isolate* v8_isolate) { 2932 Local<NativeWeakMap> NativeWeakMap::New(Isolate* v8_isolate) {
2920 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 2933 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
2921 ENTER_V8(isolate); 2934 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
2922 i::Handle<i::JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap(); 2935 i::Handle<i::JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap();
2923 i::JSWeakCollection::Initialize(weakmap, isolate); 2936 i::JSWeakCollection::Initialize(weakmap, isolate);
2924 return Utils::NativeWeakMapToLocal(weakmap); 2937 return Utils::NativeWeakMapToLocal(weakmap);
2925 } 2938 }
2926 2939
2927 2940
2928 void NativeWeakMap::Set(Local<Value> v8_key, Local<Value> v8_value) { 2941 void NativeWeakMap::Set(Local<Value> v8_key, Local<Value> v8_value) {
2929 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this); 2942 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this);
2930 i::Isolate* isolate = weak_collection->GetIsolate(); 2943 i::Isolate* isolate = weak_collection->GetIsolate();
2931 ENTER_V8(isolate); 2944 ENTER_V8(isolate);
(...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after
4927 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( 4940 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes(
4928 Local<String> key) { 4941 Local<String> key) {
4929 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4942 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4930 return GetRealNamedPropertyAttributes(context, key); 4943 return GetRealNamedPropertyAttributes(context, key);
4931 } 4944 }
4932 4945
4933 4946
4934 Local<v8::Object> v8::Object::Clone() { 4947 Local<v8::Object> v8::Object::Clone() {
4935 auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); 4948 auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
4936 auto isolate = self->GetIsolate(); 4949 auto isolate = self->GetIsolate();
4937 ENTER_V8(isolate); 4950 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
4938 auto result = isolate->factory()->CopyJSObject(self); 4951 auto result = isolate->factory()->CopyJSObject(self);
4939 CHECK(!result.is_null()); 4952 CHECK(!result.is_null());
4940 return Utils::ToLocal(result); 4953 return Utils::ToLocal(result);
4941 } 4954 }
4942 4955
4943 4956
4944 Local<v8::Context> v8::Object::CreationContext() { 4957 Local<v8::Context> v8::Object::CreationContext() {
4945 auto self = Utils::OpenHandle(this); 4958 auto self = Utils::OpenHandle(this);
4946 auto context = handle(self->GetCreationContext()); 4959 auto context = handle(self->GetCreationContext());
4947 return Utils::ToLocal(context); 4960 return Utils::ToLocal(context);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
5016 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 5029 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
5017 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); 5030 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv);
5018 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value); 5031 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value);
5019 } 5032 }
5020 5033
5021 MaybeLocal<Function> Function::New(Local<Context> context, 5034 MaybeLocal<Function> Function::New(Local<Context> context,
5022 FunctionCallback callback, Local<Value> data, 5035 FunctionCallback callback, Local<Value> data,
5023 int length, ConstructorBehavior behavior) { 5036 int length, ConstructorBehavior behavior) {
5024 i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate(); 5037 i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate();
5025 LOG_API(isolate, Function, New); 5038 LOG_API(isolate, Function, New);
5026 ENTER_V8(isolate); 5039 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
5027 auto templ = FunctionTemplateNew(isolate, callback, nullptr, data, 5040 auto templ = FunctionTemplateNew(isolate, callback, nullptr, data,
5028 Local<Signature>(), length, true); 5041 Local<Signature>(), length, true);
5029 if (behavior == ConstructorBehavior::kThrow) templ->RemovePrototype(); 5042 if (behavior == ConstructorBehavior::kThrow) templ->RemovePrototype();
5030 return templ->GetFunction(context); 5043 return templ->GetFunction(context);
5031 } 5044 }
5032 5045
5033 5046
5034 Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback, 5047 Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback,
5035 Local<Value> data, int length) { 5048 Local<Value> data, int length) {
5036 return Function::New(v8_isolate->GetCurrentContext(), callback, data, length, 5049 return Function::New(v8_isolate->GetCurrentContext(), callback, data, length,
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after
6410 global)->IsDetachedFrom(context->global_object())) { 6423 global)->IsDetachedFrom(context->global_object())) {
6411 global = i::Handle<i::Object>(context->global_object(), isolate); 6424 global = i::Handle<i::Object>(context->global_object(), isolate);
6412 } 6425 }
6413 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); 6426 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global));
6414 } 6427 }
6415 6428
6416 6429
6417 void Context::DetachGlobal() { 6430 void Context::DetachGlobal() {
6418 i::Handle<i::Context> context = Utils::OpenHandle(this); 6431 i::Handle<i::Context> context = Utils::OpenHandle(this);
6419 i::Isolate* isolate = context->GetIsolate(); 6432 i::Isolate* isolate = context->GetIsolate();
6420 ENTER_V8(isolate); 6433 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
6421 isolate->bootstrapper()->DetachGlobal(context); 6434 isolate->bootstrapper()->DetachGlobal(context);
6422 } 6435 }
6423 6436
6424 6437
6425 Local<v8::Object> Context::GetExtrasBindingObject() { 6438 Local<v8::Object> Context::GetExtrasBindingObject() {
6426 i::Handle<i::Context> context = Utils::OpenHandle(this); 6439 i::Handle<i::Context> context = Utils::OpenHandle(this);
6427 i::Isolate* isolate = context->GetIsolate(); 6440 i::Isolate* isolate = context->GetIsolate();
6428 i::Handle<i::JSObject> binding(context->extras_binding_object(), isolate); 6441 i::Handle<i::JSObject> binding(context->extras_binding_object(), isolate);
6429 return Utils::ToLocal(binding); 6442 return Utils::ToLocal(binding);
6430 } 6443 }
6431 6444
6432 6445
6433 void Context::AllowCodeGenerationFromStrings(bool allow) { 6446 void Context::AllowCodeGenerationFromStrings(bool allow) {
6434 i::Handle<i::Context> context = Utils::OpenHandle(this); 6447 i::Handle<i::Context> context = Utils::OpenHandle(this);
6435 i::Isolate* isolate = context->GetIsolate(); 6448 i::Isolate* isolate = context->GetIsolate();
6436 ENTER_V8(isolate); 6449 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
6437 context->set_allow_code_gen_from_strings( 6450 context->set_allow_code_gen_from_strings(
6438 allow ? isolate->heap()->true_value() : isolate->heap()->false_value()); 6451 allow ? isolate->heap()->true_value() : isolate->heap()->false_value());
6439 } 6452 }
6440 6453
6441 6454
6442 bool Context::IsCodeGenerationFromStringsAllowed() { 6455 bool Context::IsCodeGenerationFromStringsAllowed() {
6443 i::Handle<i::Context> context = Utils::OpenHandle(this); 6456 i::Handle<i::Context> context = Utils::OpenHandle(this);
6444 return !context->allow_code_gen_from_strings()->IsFalse( 6457 return !context->allow_code_gen_from_strings()->IsFalse(
6445 context->GetIsolate()); 6458 context->GetIsolate());
6446 } 6459 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
6532 return self->IsTemplateFor(iter.GetCurrent<i::JSGlobalObject>()); 6545 return self->IsTemplateFor(iter.GetCurrent<i::JSGlobalObject>());
6533 } 6546 }
6534 return false; 6547 return false;
6535 } 6548 }
6536 6549
6537 6550
6538 Local<External> v8::External::New(Isolate* isolate, void* value) { 6551 Local<External> v8::External::New(Isolate* isolate, void* value) {
6539 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); 6552 STATIC_ASSERT(sizeof(value) == sizeof(i::Address));
6540 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6553 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6541 LOG_API(i_isolate, External, New); 6554 LOG_API(i_isolate, External, New);
6542 ENTER_V8(i_isolate); 6555 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
6543 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value); 6556 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value);
6544 return Utils::ExternalToLocal(external); 6557 return Utils::ExternalToLocal(external);
6545 } 6558 }
6546 6559
6547 6560
6548 void* External::Value() const { 6561 void* External::Value() const {
6549 return ExternalValue(*Utils::OpenHandle(this)); 6562 return ExternalValue(*Utils::OpenHandle(this));
6550 } 6563 }
6551 6564
6552 6565
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
6611 // TODO(dcarney): throw a context free exception. 6624 // TODO(dcarney): throw a context free exception.
6612 #define NEW_STRING(isolate, class_name, function_name, Char, data, type, \ 6625 #define NEW_STRING(isolate, class_name, function_name, Char, data, type, \
6613 length) \ 6626 length) \
6614 MaybeLocal<String> result; \ 6627 MaybeLocal<String> result; \
6615 if (length == 0) { \ 6628 if (length == 0) { \
6616 result = String::Empty(isolate); \ 6629 result = String::Empty(isolate); \
6617 } else if (length > i::String::kMaxLength) { \ 6630 } else if (length > i::String::kMaxLength) { \
6618 result = MaybeLocal<String>(); \ 6631 result = MaybeLocal<String>(); \
6619 } else { \ 6632 } else { \
6620 i::Isolate* i_isolate = reinterpret_cast<internal::Isolate*>(isolate); \ 6633 i::Isolate* i_isolate = reinterpret_cast<internal::Isolate*>(isolate); \
6621 ENTER_V8(i_isolate); \ 6634 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); \
6622 LOG_API(i_isolate, class_name, function_name); \ 6635 LOG_API(i_isolate, class_name, function_name); \
6623 if (length < 0) length = StringLength(data); \ 6636 if (length < 0) length = StringLength(data); \
6624 i::Handle<i::String> handle_result = \ 6637 i::Handle<i::String> handle_result = \
6625 NewString(i_isolate->factory(), type, \ 6638 NewString(i_isolate->factory(), type, \
6626 i::Vector<const Char>(data, length)) \ 6639 i::Vector<const Char>(data, length)) \
6627 .ToHandleChecked(); \ 6640 .ToHandleChecked(); \
6628 result = Utils::ToLocal(handle_result); \ 6641 result = Utils::ToLocal(handle_result); \
6629 } 6642 }
6630 6643
6631 Local<String> String::NewFromUtf8(Isolate* isolate, 6644 Local<String> String::NewFromUtf8(Isolate* isolate,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
6698 6711
6699 6712
6700 MaybeLocal<String> v8::String::NewExternalTwoByte( 6713 MaybeLocal<String> v8::String::NewExternalTwoByte(
6701 Isolate* isolate, v8::String::ExternalStringResource* resource) { 6714 Isolate* isolate, v8::String::ExternalStringResource* resource) {
6702 CHECK(resource && resource->data()); 6715 CHECK(resource && resource->data());
6703 // TODO(dcarney): throw a context free exception. 6716 // TODO(dcarney): throw a context free exception.
6704 if (resource->length() > static_cast<size_t>(i::String::kMaxLength)) { 6717 if (resource->length() > static_cast<size_t>(i::String::kMaxLength)) {
6705 return MaybeLocal<String>(); 6718 return MaybeLocal<String>();
6706 } 6719 }
6707 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6720 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6708 ENTER_V8(i_isolate); 6721 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
6709 LOG_API(i_isolate, String, NewExternalTwoByte); 6722 LOG_API(i_isolate, String, NewExternalTwoByte);
6710 i::Handle<i::String> string = i_isolate->factory() 6723 i::Handle<i::String> string = i_isolate->factory()
6711 ->NewExternalStringFromTwoByte(resource) 6724 ->NewExternalStringFromTwoByte(resource)
6712 .ToHandleChecked(); 6725 .ToHandleChecked();
6713 i_isolate->heap()->RegisterExternalString(*string); 6726 i_isolate->heap()->RegisterExternalString(*string);
6714 return Utils::ToLocal(string); 6727 return Utils::ToLocal(string);
6715 } 6728 }
6716 6729
6717 6730
6718 Local<String> v8::String::NewExternal( 6731 Local<String> v8::String::NewExternal(
6719 Isolate* isolate, v8::String::ExternalStringResource* resource) { 6732 Isolate* isolate, v8::String::ExternalStringResource* resource) {
6720 RETURN_TO_LOCAL_UNCHECKED(NewExternalTwoByte(isolate, resource), String); 6733 RETURN_TO_LOCAL_UNCHECKED(NewExternalTwoByte(isolate, resource), String);
6721 } 6734 }
6722 6735
6723 6736
6724 MaybeLocal<String> v8::String::NewExternalOneByte( 6737 MaybeLocal<String> v8::String::NewExternalOneByte(
6725 Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) { 6738 Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) {
6726 CHECK(resource && resource->data()); 6739 CHECK(resource && resource->data());
6727 // TODO(dcarney): throw a context free exception. 6740 // TODO(dcarney): throw a context free exception.
6728 if (resource->length() > static_cast<size_t>(i::String::kMaxLength)) { 6741 if (resource->length() > static_cast<size_t>(i::String::kMaxLength)) {
6729 return MaybeLocal<String>(); 6742 return MaybeLocal<String>();
6730 } 6743 }
6731 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6744 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6732 ENTER_V8(i_isolate); 6745 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
6733 LOG_API(i_isolate, String, NewExternalOneByte); 6746 LOG_API(i_isolate, String, NewExternalOneByte);
6734 i::Handle<i::String> string = i_isolate->factory() 6747 i::Handle<i::String> string = i_isolate->factory()
6735 ->NewExternalStringFromOneByte(resource) 6748 ->NewExternalStringFromOneByte(resource)
6736 .ToHandleChecked(); 6749 .ToHandleChecked();
6737 i_isolate->heap()->RegisterExternalString(*string); 6750 i_isolate->heap()->RegisterExternalString(*string);
6738 return Utils::ToLocal(string); 6751 return Utils::ToLocal(string);
6739 } 6752 }
6740 6753
6741 6754
6742 Local<String> v8::String::NewExternal( 6755 Local<String> v8::String::NewExternal(
6743 Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) { 6756 Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) {
6744 RETURN_TO_LOCAL_UNCHECKED(NewExternalOneByte(isolate, resource), String); 6757 RETURN_TO_LOCAL_UNCHECKED(NewExternalOneByte(isolate, resource), String);
6745 } 6758 }
6746 6759
6747 6760
6748 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { 6761 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
6749 i::Handle<i::String> obj = Utils::OpenHandle(this); 6762 i::Handle<i::String> obj = Utils::OpenHandle(this);
6750 i::Isolate* isolate = obj->GetIsolate(); 6763 i::Isolate* isolate = obj->GetIsolate();
6751 if (i::StringShape(*obj).IsExternal()) { 6764 if (i::StringShape(*obj).IsExternal()) {
6752 return false; // Already an external string. 6765 return false; // Already an external string.
6753 } 6766 }
6754 ENTER_V8(isolate); 6767 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
6755 if (isolate->heap()->IsInGCPostProcessing()) { 6768 if (isolate->heap()->IsInGCPostProcessing()) {
6756 return false; 6769 return false;
6757 } 6770 }
6758 CHECK(resource && resource->data()); 6771 CHECK(resource && resource->data());
6759 6772
6760 bool result = obj->MakeExternal(resource); 6773 bool result = obj->MakeExternal(resource);
6761 // Assert that if CanMakeExternal(), then externalizing actually succeeds. 6774 // Assert that if CanMakeExternal(), then externalizing actually succeeds.
6762 DCHECK(!CanMakeExternal() || result); 6775 DCHECK(!CanMakeExternal() || result);
6763 if (result) { 6776 if (result) {
6764 DCHECK(obj->IsExternalString()); 6777 DCHECK(obj->IsExternalString());
6765 isolate->heap()->RegisterExternalString(*obj); 6778 isolate->heap()->RegisterExternalString(*obj);
6766 } 6779 }
6767 return result; 6780 return result;
6768 } 6781 }
6769 6782
6770 6783
6771 bool v8::String::MakeExternal( 6784 bool v8::String::MakeExternal(
6772 v8::String::ExternalOneByteStringResource* resource) { 6785 v8::String::ExternalOneByteStringResource* resource) {
6773 i::Handle<i::String> obj = Utils::OpenHandle(this); 6786 i::Handle<i::String> obj = Utils::OpenHandle(this);
6774 i::Isolate* isolate = obj->GetIsolate(); 6787 i::Isolate* isolate = obj->GetIsolate();
6775 if (i::StringShape(*obj).IsExternal()) { 6788 if (i::StringShape(*obj).IsExternal()) {
6776 return false; // Already an external string. 6789 return false; // Already an external string.
6777 } 6790 }
6778 ENTER_V8(isolate); 6791 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
6779 if (isolate->heap()->IsInGCPostProcessing()) { 6792 if (isolate->heap()->IsInGCPostProcessing()) {
6780 return false; 6793 return false;
6781 } 6794 }
6782 CHECK(resource && resource->data()); 6795 CHECK(resource && resource->data());
6783 6796
6784 bool result = obj->MakeExternal(resource); 6797 bool result = obj->MakeExternal(resource);
6785 // Assert that if CanMakeExternal(), then externalizing actually succeeds. 6798 // Assert that if CanMakeExternal(), then externalizing actually succeeds.
6786 DCHECK(!CanMakeExternal() || result); 6799 DCHECK(!CanMakeExternal() || result);
6787 if (result) { 6800 if (result) {
6788 DCHECK(obj->IsExternalString()); 6801 DCHECK(obj->IsExternalString());
(...skipping 15 matching lines...) Expand all
6804 6817
6805 Isolate* v8::Object::GetIsolate() { 6818 Isolate* v8::Object::GetIsolate() {
6806 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); 6819 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate();
6807 return reinterpret_cast<Isolate*>(i_isolate); 6820 return reinterpret_cast<Isolate*>(i_isolate);
6808 } 6821 }
6809 6822
6810 6823
6811 Local<v8::Object> v8::Object::New(Isolate* isolate) { 6824 Local<v8::Object> v8::Object::New(Isolate* isolate) {
6812 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6825 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6813 LOG_API(i_isolate, Object, New); 6826 LOG_API(i_isolate, Object, New);
6814 ENTER_V8(i_isolate); 6827 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
6815 i::Handle<i::JSObject> obj = 6828 i::Handle<i::JSObject> obj =
6816 i_isolate->factory()->NewJSObject(i_isolate->object_function()); 6829 i_isolate->factory()->NewJSObject(i_isolate->object_function());
6817 return Utils::ToLocal(obj); 6830 return Utils::ToLocal(obj);
6818 } 6831 }
6819 6832
6820 6833
6821 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) { 6834 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) {
6822 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6835 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6823 LOG_API(i_isolate, NumberObject, New); 6836 LOG_API(i_isolate, NumberObject, New);
6824 ENTER_V8(i_isolate); 6837 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
6825 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); 6838 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value);
6826 i::Handle<i::Object> obj = 6839 i::Handle<i::Object> obj =
6827 i::Object::ToObject(i_isolate, number).ToHandleChecked(); 6840 i::Object::ToObject(i_isolate, number).ToHandleChecked();
6828 return Utils::ToLocal(obj); 6841 return Utils::ToLocal(obj);
6829 } 6842 }
6830 6843
6831 6844
6832 double v8::NumberObject::ValueOf() const { 6845 double v8::NumberObject::ValueOf() const {
6833 i::Handle<i::Object> obj = Utils::OpenHandle(this); 6846 i::Handle<i::Object> obj = Utils::OpenHandle(this);
6834 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 6847 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
6835 i::Isolate* isolate = jsvalue->GetIsolate(); 6848 i::Isolate* isolate = jsvalue->GetIsolate();
6836 LOG_API(isolate, NumberObject, NumberValue); 6849 LOG_API(isolate, NumberObject, NumberValue);
6837 return jsvalue->value()->Number(); 6850 return jsvalue->value()->Number();
6838 } 6851 }
6839 6852
6840 6853
6841 Local<v8::Value> v8::BooleanObject::New(Isolate* isolate, bool value) { 6854 Local<v8::Value> v8::BooleanObject::New(Isolate* isolate, bool value) {
6842 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6855 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6843 LOG_API(i_isolate, BooleanObject, New); 6856 LOG_API(i_isolate, BooleanObject, New);
6844 ENTER_V8(i_isolate); 6857 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
6845 i::Handle<i::Object> boolean(value ? i_isolate->heap()->true_value() 6858 i::Handle<i::Object> boolean(value ? i_isolate->heap()->true_value()
6846 : i_isolate->heap()->false_value(), 6859 : i_isolate->heap()->false_value(),
6847 i_isolate); 6860 i_isolate);
6848 i::Handle<i::Object> obj = 6861 i::Handle<i::Object> obj =
6849 i::Object::ToObject(i_isolate, boolean).ToHandleChecked(); 6862 i::Object::ToObject(i_isolate, boolean).ToHandleChecked();
6850 return Utils::ToLocal(obj); 6863 return Utils::ToLocal(obj);
6851 } 6864 }
6852 6865
6853 6866
6854 Local<v8::Value> v8::BooleanObject::New(bool value) { 6867 Local<v8::Value> v8::BooleanObject::New(bool value) {
6855 return New(Isolate::GetCurrent(), value); 6868 return New(Isolate::GetCurrent(), value);
6856 } 6869 }
6857 6870
6858 6871
6859 bool v8::BooleanObject::ValueOf() const { 6872 bool v8::BooleanObject::ValueOf() const {
6860 i::Handle<i::Object> obj = Utils::OpenHandle(this); 6873 i::Handle<i::Object> obj = Utils::OpenHandle(this);
6861 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 6874 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
6862 i::Isolate* isolate = jsvalue->GetIsolate(); 6875 i::Isolate* isolate = jsvalue->GetIsolate();
6863 LOG_API(isolate, BooleanObject, BooleanValue); 6876 LOG_API(isolate, BooleanObject, BooleanValue);
6864 return jsvalue->value()->IsTrue(isolate); 6877 return jsvalue->value()->IsTrue(isolate);
6865 } 6878 }
6866 6879
6867 6880
6868 Local<v8::Value> v8::StringObject::New(Local<String> value) { 6881 Local<v8::Value> v8::StringObject::New(Local<String> value) {
6869 i::Handle<i::String> string = Utils::OpenHandle(*value); 6882 i::Handle<i::String> string = Utils::OpenHandle(*value);
6870 i::Isolate* isolate = string->GetIsolate(); 6883 i::Isolate* isolate = string->GetIsolate();
6871 LOG_API(isolate, StringObject, New); 6884 LOG_API(isolate, StringObject, New);
6872 ENTER_V8(isolate); 6885 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
6873 i::Handle<i::Object> obj = 6886 i::Handle<i::Object> obj =
6874 i::Object::ToObject(isolate, string).ToHandleChecked(); 6887 i::Object::ToObject(isolate, string).ToHandleChecked();
6875 return Utils::ToLocal(obj); 6888 return Utils::ToLocal(obj);
6876 } 6889 }
6877 6890
6878 6891
6879 Local<v8::String> v8::StringObject::ValueOf() const { 6892 Local<v8::String> v8::StringObject::ValueOf() const {
6880 i::Handle<i::Object> obj = Utils::OpenHandle(this); 6893 i::Handle<i::Object> obj = Utils::OpenHandle(this);
6881 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 6894 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
6882 i::Isolate* isolate = jsvalue->GetIsolate(); 6895 i::Isolate* isolate = jsvalue->GetIsolate();
6883 LOG_API(isolate, StringObject, StringValue); 6896 LOG_API(isolate, StringObject, StringValue);
6884 return Utils::ToLocal( 6897 return Utils::ToLocal(
6885 i::Handle<i::String>(i::String::cast(jsvalue->value()))); 6898 i::Handle<i::String>(i::String::cast(jsvalue->value())));
6886 } 6899 }
6887 6900
6888 6901
6889 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Local<Symbol> value) { 6902 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Local<Symbol> value) {
6890 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6903 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6891 LOG_API(i_isolate, SymbolObject, New); 6904 LOG_API(i_isolate, SymbolObject, New);
6892 ENTER_V8(i_isolate); 6905 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
6893 i::Handle<i::Object> obj = i::Object::ToObject( 6906 i::Handle<i::Object> obj = i::Object::ToObject(
6894 i_isolate, Utils::OpenHandle(*value)).ToHandleChecked(); 6907 i_isolate, Utils::OpenHandle(*value)).ToHandleChecked();
6895 return Utils::ToLocal(obj); 6908 return Utils::ToLocal(obj);
6896 } 6909 }
6897 6910
6898 6911
6899 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { 6912 Local<v8::Symbol> v8::SymbolObject::ValueOf() const {
6900 i::Handle<i::Object> obj = Utils::OpenHandle(this); 6913 i::Handle<i::Object> obj = Utils::OpenHandle(this);
6901 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 6914 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
6902 i::Isolate* isolate = jsvalue->GetIsolate(); 6915 i::Isolate* isolate = jsvalue->GetIsolate();
(...skipping 29 matching lines...) Expand all
6932 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); 6945 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj);
6933 i::Isolate* isolate = jsdate->GetIsolate(); 6946 i::Isolate* isolate = jsdate->GetIsolate();
6934 LOG_API(isolate, Date, NumberValue); 6947 LOG_API(isolate, Date, NumberValue);
6935 return jsdate->value()->Number(); 6948 return jsdate->value()->Number();
6936 } 6949 }
6937 6950
6938 6951
6939 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { 6952 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) {
6940 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6953 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6941 LOG_API(i_isolate, Date, DateTimeConfigurationChangeNotification); 6954 LOG_API(i_isolate, Date, DateTimeConfigurationChangeNotification);
6942 ENTER_V8(i_isolate); 6955 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
6943 i_isolate->date_cache()->ResetDateCache(); 6956 i_isolate->date_cache()->ResetDateCache();
6944 if (!i_isolate->eternal_handles()->Exists( 6957 if (!i_isolate->eternal_handles()->Exists(
6945 i::EternalHandles::DATE_CACHE_VERSION)) { 6958 i::EternalHandles::DATE_CACHE_VERSION)) {
6946 return; 6959 return;
6947 } 6960 }
6948 i::Handle<i::FixedArray> date_cache_version = 6961 i::Handle<i::FixedArray> date_cache_version =
6949 i::Handle<i::FixedArray>::cast(i_isolate->eternal_handles()->GetSingleton( 6962 i::Handle<i::FixedArray>::cast(i_isolate->eternal_handles()->GetSingleton(
6950 i::EternalHandles::DATE_CACHE_VERSION)); 6963 i::EternalHandles::DATE_CACHE_VERSION));
6951 DCHECK_EQ(1, date_cache_version->length()); 6964 DCHECK_EQ(1, date_cache_version->length());
6952 CHECK(date_cache_version->get(0)->IsSmi()); 6965 CHECK(date_cache_version->get(0)->IsSmi());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
6997 7010
6998 v8::RegExp::Flags v8::RegExp::GetFlags() const { 7011 v8::RegExp::Flags v8::RegExp::GetFlags() const {
6999 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); 7012 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this);
7000 return RegExp::Flags(static_cast<int>(obj->GetFlags())); 7013 return RegExp::Flags(static_cast<int>(obj->GetFlags()));
7001 } 7014 }
7002 7015
7003 7016
7004 Local<v8::Array> v8::Array::New(Isolate* isolate, int length) { 7017 Local<v8::Array> v8::Array::New(Isolate* isolate, int length) {
7005 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7018 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7006 LOG_API(i_isolate, Array, New); 7019 LOG_API(i_isolate, Array, New);
7007 ENTER_V8(i_isolate); 7020 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
7008 int real_length = length > 0 ? length : 0; 7021 int real_length = length > 0 ? length : 0;
7009 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length); 7022 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length);
7010 i::Handle<i::Object> length_obj = 7023 i::Handle<i::Object> length_obj =
7011 i_isolate->factory()->NewNumberFromInt(real_length); 7024 i_isolate->factory()->NewNumberFromInt(real_length);
7012 obj->set_length(*length_obj); 7025 obj->set_length(*length_obj);
7013 return Utils::ToLocal(obj); 7026 return Utils::ToLocal(obj);
7014 } 7027 }
7015 7028
7016 7029
7017 uint32_t v8::Array::Length() const { 7030 uint32_t v8::Array::Length() const {
(...skipping 24 matching lines...) Expand all
7042 RETURN_ESCAPED(result); 7055 RETURN_ESCAPED(result);
7043 } 7056 }
7044 7057
7045 7058
7046 Local<Object> Array::CloneElementAt(uint32_t index) { return Local<Object>(); } 7059 Local<Object> Array::CloneElementAt(uint32_t index) { return Local<Object>(); }
7047 7060
7048 7061
7049 Local<v8::Map> v8::Map::New(Isolate* isolate) { 7062 Local<v8::Map> v8::Map::New(Isolate* isolate) {
7050 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7063 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7051 LOG_API(i_isolate, Map, New); 7064 LOG_API(i_isolate, Map, New);
7052 ENTER_V8(i_isolate); 7065 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
7053 i::Handle<i::JSMap> obj = i_isolate->factory()->NewJSMap(); 7066 i::Handle<i::JSMap> obj = i_isolate->factory()->NewJSMap();
7054 return Utils::ToLocal(obj); 7067 return Utils::ToLocal(obj);
7055 } 7068 }
7056 7069
7057 7070
7058 size_t v8::Map::Size() const { 7071 size_t v8::Map::Size() const {
7059 i::Handle<i::JSMap> obj = Utils::OpenHandle(this); 7072 i::Handle<i::JSMap> obj = Utils::OpenHandle(this);
7060 return i::OrderedHashMap::cast(obj->table())->NumberOfElements(); 7073 return i::OrderedHashMap::cast(obj->table())->NumberOfElements();
7061 } 7074 }
7062 7075
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
7150 DCHECK_EQ(result_index, length); 7163 DCHECK_EQ(result_index, length);
7151 i::Handle<i::JSArray> result_array = 7164 i::Handle<i::JSArray> result_array =
7152 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); 7165 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length);
7153 return Utils::ToLocal(result_array); 7166 return Utils::ToLocal(result_array);
7154 } 7167 }
7155 7168
7156 7169
7157 Local<v8::Set> v8::Set::New(Isolate* isolate) { 7170 Local<v8::Set> v8::Set::New(Isolate* isolate) {
7158 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7171 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7159 LOG_API(i_isolate, Set, New); 7172 LOG_API(i_isolate, Set, New);
7160 ENTER_V8(i_isolate); 7173 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
7161 i::Handle<i::JSSet> obj = i_isolate->factory()->NewJSSet(); 7174 i::Handle<i::JSSet> obj = i_isolate->factory()->NewJSSet();
7162 return Utils::ToLocal(obj); 7175 return Utils::ToLocal(obj);
7163 } 7176 }
7164 7177
7165 7178
7166 size_t v8::Set::Size() const { 7179 size_t v8::Set::Size() const {
7167 i::Handle<i::JSSet> obj = Utils::OpenHandle(this); 7180 i::Handle<i::JSSet> obj = Utils::OpenHandle(this);
7168 return i::OrderedHashSet::cast(obj->table())->NumberOfElements(); 7181 return i::OrderedHashSet::cast(obj->table())->NumberOfElements();
7169 } 7182 }
7170 7183
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
7532 7545
7533 void v8::ArrayBuffer::Neuter() { 7546 void v8::ArrayBuffer::Neuter() {
7534 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 7547 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
7535 i::Isolate* isolate = obj->GetIsolate(); 7548 i::Isolate* isolate = obj->GetIsolate();
7536 Utils::ApiCheck(obj->is_external(), 7549 Utils::ApiCheck(obj->is_external(),
7537 "v8::ArrayBuffer::Neuter", 7550 "v8::ArrayBuffer::Neuter",
7538 "Only externalized ArrayBuffers can be neutered"); 7551 "Only externalized ArrayBuffers can be neutered");
7539 Utils::ApiCheck(obj->is_neuterable(), "v8::ArrayBuffer::Neuter", 7552 Utils::ApiCheck(obj->is_neuterable(), "v8::ArrayBuffer::Neuter",
7540 "Only neuterable ArrayBuffers can be neutered"); 7553 "Only neuterable ArrayBuffers can be neutered");
7541 LOG_API(isolate, ArrayBuffer, Neuter); 7554 LOG_API(isolate, ArrayBuffer, Neuter);
7542 ENTER_V8(isolate); 7555 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
7543 obj->Neuter(); 7556 obj->Neuter();
7544 } 7557 }
7545 7558
7546 7559
7547 size_t v8::ArrayBuffer::ByteLength() const { 7560 size_t v8::ArrayBuffer::ByteLength() const {
7548 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 7561 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
7549 return static_cast<size_t>(obj->byte_length()->Number()); 7562 return static_cast<size_t>(obj->byte_length()->Number());
7550 } 7563 }
7551 7564
7552 7565
7553 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) { 7566 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) {
7554 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7567 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7555 LOG_API(i_isolate, ArrayBuffer, New); 7568 LOG_API(i_isolate, ArrayBuffer, New);
7556 ENTER_V8(i_isolate); 7569 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
7557 i::Handle<i::JSArrayBuffer> obj = 7570 i::Handle<i::JSArrayBuffer> obj =
7558 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); 7571 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared);
7559 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length); 7572 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length);
7560 return Utils::ToLocal(obj); 7573 return Utils::ToLocal(obj);
7561 } 7574 }
7562 7575
7563 7576
7564 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, 7577 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data,
7565 size_t byte_length, 7578 size_t byte_length,
7566 ArrayBufferCreationMode mode) { 7579 ArrayBufferCreationMode mode) {
7567 // Embedders must guarantee that the external backing store is valid. 7580 // Embedders must guarantee that the external backing store is valid.
7568 CHECK(byte_length == 0 || data != NULL); 7581 CHECK(byte_length == 0 || data != NULL);
7569 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7582 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7570 LOG_API(i_isolate, ArrayBuffer, New); 7583 LOG_API(i_isolate, ArrayBuffer, New);
7571 ENTER_V8(i_isolate); 7584 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
7572 i::Handle<i::JSArrayBuffer> obj = 7585 i::Handle<i::JSArrayBuffer> obj =
7573 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); 7586 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared);
7574 i::JSArrayBuffer::Setup(obj, i_isolate, 7587 i::JSArrayBuffer::Setup(obj, i_isolate,
7575 mode == ArrayBufferCreationMode::kExternalized, data, 7588 mode == ArrayBufferCreationMode::kExternalized, data,
7576 byte_length); 7589 byte_length);
7577 return Utils::ToLocal(obj); 7590 return Utils::ToLocal(obj);
7578 } 7591 }
7579 7592
7580 7593
7581 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { 7594 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
7637 size_t v8::TypedArray::Length() { 7650 size_t v8::TypedArray::Length() {
7638 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this); 7651 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this);
7639 return static_cast<size_t>(obj->length_value()); 7652 return static_cast<size_t>(obj->length_value());
7640 } 7653 }
7641 7654
7642 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \ 7655 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \
7643 Local<Type##Array> Type##Array::New(Local<ArrayBuffer> array_buffer, \ 7656 Local<Type##Array> Type##Array::New(Local<ArrayBuffer> array_buffer, \
7644 size_t byte_offset, size_t length) { \ 7657 size_t byte_offset, size_t length) { \
7645 i::Isolate* isolate = Utils::OpenHandle(*array_buffer)->GetIsolate(); \ 7658 i::Isolate* isolate = Utils::OpenHandle(*array_buffer)->GetIsolate(); \
7646 LOG_API(isolate, Type##Array, New); \ 7659 LOG_API(isolate, Type##Array, New); \
7647 ENTER_V8(isolate); \ 7660 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); \
7648 if (!Utils::ApiCheck(length <= static_cast<size_t>(i::Smi::kMaxValue), \ 7661 if (!Utils::ApiCheck(length <= static_cast<size_t>(i::Smi::kMaxValue), \
7649 "v8::" #Type \ 7662 "v8::" #Type \
7650 "Array::New(Local<ArrayBuffer>, size_t, size_t)", \ 7663 "Array::New(Local<ArrayBuffer>, size_t, size_t)", \
7651 "length exceeds max allowed value")) { \ 7664 "length exceeds max allowed value")) { \
7652 return Local<Type##Array>(); \ 7665 return Local<Type##Array>(); \
7653 } \ 7666 } \
7654 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); \ 7667 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); \
7655 i::Handle<i::JSTypedArray> obj = isolate->factory()->NewJSTypedArray( \ 7668 i::Handle<i::JSTypedArray> obj = isolate->factory()->NewJSTypedArray( \
7656 i::kExternal##Type##Array, buffer, byte_offset, length); \ 7669 i::kExternal##Type##Array, buffer, byte_offset, length); \
7657 return Utils::ToLocal##Type##Array(obj); \ 7670 return Utils::ToLocal##Type##Array(obj); \
7658 } \ 7671 } \
7659 Local<Type##Array> Type##Array::New( \ 7672 Local<Type##Array> Type##Array::New( \
7660 Local<SharedArrayBuffer> shared_array_buffer, size_t byte_offset, \ 7673 Local<SharedArrayBuffer> shared_array_buffer, size_t byte_offset, \
7661 size_t length) { \ 7674 size_t length) { \
7662 CHECK(i::FLAG_harmony_sharedarraybuffer); \ 7675 CHECK(i::FLAG_harmony_sharedarraybuffer); \
7663 i::Isolate* isolate = \ 7676 i::Isolate* isolate = \
7664 Utils::OpenHandle(*shared_array_buffer)->GetIsolate(); \ 7677 Utils::OpenHandle(*shared_array_buffer)->GetIsolate(); \
7665 LOG_API(isolate, Type##Array, New); \ 7678 LOG_API(isolate, Type##Array, New); \
7666 ENTER_V8(isolate); \ 7679 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); \
7667 if (!Utils::ApiCheck( \ 7680 if (!Utils::ApiCheck( \
7668 length <= static_cast<size_t>(i::Smi::kMaxValue), \ 7681 length <= static_cast<size_t>(i::Smi::kMaxValue), \
7669 "v8::" #Type \ 7682 "v8::" #Type \
7670 "Array::New(Local<SharedArrayBuffer>, size_t, size_t)", \ 7683 "Array::New(Local<SharedArrayBuffer>, size_t, size_t)", \
7671 "length exceeds max allowed value")) { \ 7684 "length exceeds max allowed value")) { \
7672 return Local<Type##Array>(); \ 7685 return Local<Type##Array>(); \
7673 } \ 7686 } \
7674 i::Handle<i::JSArrayBuffer> buffer = \ 7687 i::Handle<i::JSArrayBuffer> buffer = \
7675 Utils::OpenHandle(*shared_array_buffer); \ 7688 Utils::OpenHandle(*shared_array_buffer); \
7676 i::Handle<i::JSTypedArray> obj = isolate->factory()->NewJSTypedArray( \ 7689 i::Handle<i::JSTypedArray> obj = isolate->factory()->NewJSTypedArray( \
7677 i::kExternal##Type##Array, buffer, byte_offset, length); \ 7690 i::kExternal##Type##Array, buffer, byte_offset, length); \
7678 return Utils::ToLocal##Type##Array(obj); \ 7691 return Utils::ToLocal##Type##Array(obj); \
7679 } 7692 }
7680 7693
7681 TYPED_ARRAYS(TYPED_ARRAY_NEW) 7694 TYPED_ARRAYS(TYPED_ARRAY_NEW)
7682 #undef TYPED_ARRAY_NEW 7695 #undef TYPED_ARRAY_NEW
7683 7696
7684 Local<DataView> DataView::New(Local<ArrayBuffer> array_buffer, 7697 Local<DataView> DataView::New(Local<ArrayBuffer> array_buffer,
7685 size_t byte_offset, size_t byte_length) { 7698 size_t byte_offset, size_t byte_length) {
7686 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); 7699 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer);
7687 i::Isolate* isolate = buffer->GetIsolate(); 7700 i::Isolate* isolate = buffer->GetIsolate();
7688 LOG_API(isolate, DataView, New); 7701 LOG_API(isolate, DataView, New);
7689 ENTER_V8(isolate); 7702 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
7690 i::Handle<i::JSDataView> obj = 7703 i::Handle<i::JSDataView> obj =
7691 isolate->factory()->NewJSDataView(buffer, byte_offset, byte_length); 7704 isolate->factory()->NewJSDataView(buffer, byte_offset, byte_length);
7692 return Utils::ToLocal(obj); 7705 return Utils::ToLocal(obj);
7693 } 7706 }
7694 7707
7695 7708
7696 Local<DataView> DataView::New(Local<SharedArrayBuffer> shared_array_buffer, 7709 Local<DataView> DataView::New(Local<SharedArrayBuffer> shared_array_buffer,
7697 size_t byte_offset, size_t byte_length) { 7710 size_t byte_offset, size_t byte_length) {
7698 CHECK(i::FLAG_harmony_sharedarraybuffer); 7711 CHECK(i::FLAG_harmony_sharedarraybuffer);
7699 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*shared_array_buffer); 7712 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*shared_array_buffer);
7700 i::Isolate* isolate = buffer->GetIsolate(); 7713 i::Isolate* isolate = buffer->GetIsolate();
7701 LOG_API(isolate, DataView, New); 7714 LOG_API(isolate, DataView, New);
7702 ENTER_V8(isolate); 7715 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
7703 i::Handle<i::JSDataView> obj = 7716 i::Handle<i::JSDataView> obj =
7704 isolate->factory()->NewJSDataView(buffer, byte_offset, byte_length); 7717 isolate->factory()->NewJSDataView(buffer, byte_offset, byte_length);
7705 return Utils::ToLocal(obj); 7718 return Utils::ToLocal(obj);
7706 } 7719 }
7707 7720
7708 7721
7709 bool v8::SharedArrayBuffer::IsExternal() const { 7722 bool v8::SharedArrayBuffer::IsExternal() const {
7710 return Utils::OpenHandle(this)->is_external(); 7723 return Utils::OpenHandle(this)->is_external();
7711 } 7724 }
7712 7725
(...skipping 23 matching lines...) Expand all
7736 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 7749 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
7737 return static_cast<size_t>(obj->byte_length()->Number()); 7750 return static_cast<size_t>(obj->byte_length()->Number());
7738 } 7751 }
7739 7752
7740 7753
7741 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate, 7754 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate,
7742 size_t byte_length) { 7755 size_t byte_length) {
7743 CHECK(i::FLAG_harmony_sharedarraybuffer); 7756 CHECK(i::FLAG_harmony_sharedarraybuffer);
7744 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7757 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7745 LOG_API(i_isolate, SharedArrayBuffer, New); 7758 LOG_API(i_isolate, SharedArrayBuffer, New);
7746 ENTER_V8(i_isolate); 7759 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
7747 i::Handle<i::JSArrayBuffer> obj = 7760 i::Handle<i::JSArrayBuffer> obj =
7748 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); 7761 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared);
7749 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true, 7762 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true,
7750 i::SharedFlag::kShared); 7763 i::SharedFlag::kShared);
7751 return Utils::ToLocalShared(obj); 7764 return Utils::ToLocalShared(obj);
7752 } 7765 }
7753 7766
7754 7767
7755 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New( 7768 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(
7756 Isolate* isolate, void* data, size_t byte_length, 7769 Isolate* isolate, void* data, size_t byte_length,
7757 ArrayBufferCreationMode mode) { 7770 ArrayBufferCreationMode mode) {
7758 CHECK(i::FLAG_harmony_sharedarraybuffer); 7771 CHECK(i::FLAG_harmony_sharedarraybuffer);
7759 // Embedders must guarantee that the external backing store is valid. 7772 // Embedders must guarantee that the external backing store is valid.
7760 CHECK(byte_length == 0 || data != NULL); 7773 CHECK(byte_length == 0 || data != NULL);
7761 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7774 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7762 LOG_API(i_isolate, SharedArrayBuffer, New); 7775 LOG_API(i_isolate, SharedArrayBuffer, New);
7763 ENTER_V8(i_isolate); 7776 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
7764 i::Handle<i::JSArrayBuffer> obj = 7777 i::Handle<i::JSArrayBuffer> obj =
7765 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); 7778 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared);
7766 i::JSArrayBuffer::Setup(obj, i_isolate, 7779 i::JSArrayBuffer::Setup(obj, i_isolate,
7767 mode == ArrayBufferCreationMode::kExternalized, data, 7780 mode == ArrayBufferCreationMode::kExternalized, data,
7768 byte_length, i::SharedFlag::kShared); 7781 byte_length, i::SharedFlag::kShared);
7769 return Utils::ToLocalShared(obj); 7782 return Utils::ToLocalShared(obj);
7770 } 7783 }
7771 7784
7772 7785
7773 Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) { 7786 Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) {
7774 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7787 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7775 LOG_API(i_isolate, Symbol, New); 7788 LOG_API(i_isolate, Symbol, New);
7776 ENTER_V8(i_isolate); 7789 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
7777 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); 7790 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol();
7778 if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name)); 7791 if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name));
7779 return Utils::ToLocal(result); 7792 return Utils::ToLocal(result);
7780 } 7793 }
7781 7794
7782 7795
7783 Local<Symbol> v8::Symbol::For(Isolate* isolate, Local<String> name) { 7796 Local<Symbol> v8::Symbol::For(Isolate* isolate, Local<String> name) {
7784 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7797 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7785 i::Handle<i::String> i_name = Utils::OpenHandle(*name); 7798 i::Handle<i::String> i_name = Utils::OpenHandle(*name);
7786 return Utils::ToLocal(i_isolate->SymbolFor( 7799 return Utils::ToLocal(i_isolate->SymbolFor(
(...skipping 29 matching lines...) Expand all
7816 7829
7817 Local<Symbol> v8::Symbol::GetIsConcatSpreadable(Isolate* isolate) { 7830 Local<Symbol> v8::Symbol::GetIsConcatSpreadable(Isolate* isolate) {
7818 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7831 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7819 return Utils::ToLocal(i_isolate->factory()->is_concat_spreadable_symbol()); 7832 return Utils::ToLocal(i_isolate->factory()->is_concat_spreadable_symbol());
7820 } 7833 }
7821 7834
7822 7835
7823 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { 7836 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) {
7824 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7837 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7825 LOG_API(i_isolate, Private, New); 7838 LOG_API(i_isolate, Private, New);
7826 ENTER_V8(i_isolate); 7839 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
7827 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); 7840 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol();
7828 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); 7841 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name));
7829 Local<Symbol> result = Utils::ToLocal(symbol); 7842 Local<Symbol> result = Utils::ToLocal(symbol);
7830 return v8::Local<Private>(reinterpret_cast<Private*>(*result)); 7843 return v8::Local<Private>(reinterpret_cast<Private*>(*result));
7831 } 7844 }
7832 7845
7833 7846
7834 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) { 7847 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) {
7835 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 7848 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
7836 i::Handle<i::String> i_name = Utils::OpenHandle(*name); 7849 i::Handle<i::String> i_name = Utils::OpenHandle(*name);
7837 Local<Symbol> result = Utils::ToLocal(i_isolate->SymbolFor( 7850 Local<Symbol> result = Utils::ToLocal(i_isolate->SymbolFor(
7838 i::Heap::kApiPrivateSymbolTableRootIndex, i_name, true)); 7851 i::Heap::kApiPrivateSymbolTableRootIndex, i_name, true));
7839 return v8::Local<Private>(reinterpret_cast<Private*>(*result)); 7852 return v8::Local<Private>(reinterpret_cast<Private*>(*result));
7840 } 7853 }
7841 7854
7842 7855
7843 Local<Number> v8::Number::New(Isolate* isolate, double value) { 7856 Local<Number> v8::Number::New(Isolate* isolate, double value) {
7844 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 7857 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
7845 if (std::isnan(value)) { 7858 if (std::isnan(value)) {
7846 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. 7859 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
7847 value = std::numeric_limits<double>::quiet_NaN(); 7860 value = std::numeric_limits<double>::quiet_NaN();
7848 } 7861 }
7849 ENTER_V8(internal_isolate); 7862 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(internal_isolate);
7850 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); 7863 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
7851 return Utils::NumberToLocal(result); 7864 return Utils::NumberToLocal(result);
7852 } 7865 }
7853 7866
7854 7867
7855 Local<Integer> v8::Integer::New(Isolate* isolate, int32_t value) { 7868 Local<Integer> v8::Integer::New(Isolate* isolate, int32_t value) {
7856 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 7869 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
7857 if (i::Smi::IsValid(value)) { 7870 if (i::Smi::IsValid(value)) {
7858 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value), 7871 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value),
7859 internal_isolate)); 7872 internal_isolate));
7860 } 7873 }
7861 ENTER_V8(internal_isolate); 7874 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(internal_isolate);
7862 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); 7875 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
7863 return Utils::IntegerToLocal(result); 7876 return Utils::IntegerToLocal(result);
7864 } 7877 }
7865 7878
7866 7879
7867 Local<Integer> v8::Integer::NewFromUnsigned(Isolate* isolate, uint32_t value) { 7880 Local<Integer> v8::Integer::NewFromUnsigned(Isolate* isolate, uint32_t value) {
7868 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 7881 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
7869 bool fits_into_int32_t = (value & (1 << 31)) == 0; 7882 bool fits_into_int32_t = (value & (1 << 31)) == 0;
7870 if (fits_into_int32_t) { 7883 if (fits_into_int32_t) {
7871 return Integer::New(isolate, static_cast<int32_t>(value)); 7884 return Integer::New(isolate, static_cast<int32_t>(value));
7872 } 7885 }
7873 ENTER_V8(internal_isolate); 7886 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(internal_isolate);
7874 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); 7887 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
7875 return Utils::IntegerToLocal(result); 7888 return Utils::IntegerToLocal(result);
7876 } 7889 }
7877 7890
7878 7891
7879 void Isolate::ReportExternalAllocationLimitReached() { 7892 void Isolate::ReportExternalAllocationLimitReached() {
7880 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); 7893 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap();
7881 if (heap->gc_state() != i::Heap::NOT_IN_GC) return; 7894 if (heap->gc_state() != i::Heap::NOT_IN_GC) return;
7882 heap->ReportExternalMemoryPressure(); 7895 heap->ReportExternalMemoryPressure();
7883 } 7896 }
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
8580 } 8593 }
8581 8594
8582 bool Isolate::AddMessageListener(MessageCallback that, Local<Value> data) { 8595 bool Isolate::AddMessageListener(MessageCallback that, Local<Value> data) {
8583 return AddMessageListenerWithErrorLevel(that, kMessageError, data); 8596 return AddMessageListenerWithErrorLevel(that, kMessageError, data);
8584 } 8597 }
8585 8598
8586 bool Isolate::AddMessageListenerWithErrorLevel(MessageCallback that, 8599 bool Isolate::AddMessageListenerWithErrorLevel(MessageCallback that,
8587 int message_levels, 8600 int message_levels,
8588 Local<Value> data) { 8601 Local<Value> data) {
8589 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 8602 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
8590 ENTER_V8(isolate); 8603 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
8591 i::HandleScope scope(isolate); 8604 i::HandleScope scope(isolate);
8592 i::Handle<i::TemplateList> list = isolate->factory()->message_listeners(); 8605 i::Handle<i::TemplateList> list = isolate->factory()->message_listeners();
8593 i::Handle<i::FixedArray> listener = isolate->factory()->NewFixedArray(3); 8606 i::Handle<i::FixedArray> listener = isolate->factory()->NewFixedArray(3);
8594 i::Handle<i::Foreign> foreign = 8607 i::Handle<i::Foreign> foreign =
8595 isolate->factory()->NewForeign(FUNCTION_ADDR(that)); 8608 isolate->factory()->NewForeign(FUNCTION_ADDR(that));
8596 listener->set(0, *foreign); 8609 listener->set(0, *foreign);
8597 listener->set(1, data.IsEmpty() ? isolate->heap()->undefined_value() 8610 listener->set(1, data.IsEmpty() ? isolate->heap()->undefined_value()
8598 : *Utils::OpenHandle(*data)); 8611 : *Utils::OpenHandle(*data));
8599 listener->set(2, i::Smi::FromInt(message_levels)); 8612 listener->set(2, i::Smi::FromInt(message_levels));
8600 list = i::TemplateList::Add(isolate, list, listener); 8613 list = i::TemplateList::Add(isolate, list, listener);
8601 isolate->heap()->SetMessageListeners(*list); 8614 isolate->heap()->SetMessageListeners(*list);
8602 return true; 8615 return true;
8603 } 8616 }
8604 8617
8605 8618
8606 void Isolate::RemoveMessageListeners(MessageCallback that) { 8619 void Isolate::RemoveMessageListeners(MessageCallback that) {
8607 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 8620 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
8608 ENTER_V8(isolate); 8621 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
8609 i::HandleScope scope(isolate); 8622 i::HandleScope scope(isolate);
8610 i::DisallowHeapAllocation no_gc; 8623 i::DisallowHeapAllocation no_gc;
8611 i::TemplateList* listeners = isolate->heap()->message_listeners(); 8624 i::TemplateList* listeners = isolate->heap()->message_listeners();
8612 for (int i = 0; i < listeners->length(); i++) { 8625 for (int i = 0; i < listeners->length(); i++) {
8613 if (listeners->get(i)->IsUndefined(isolate)) continue; // skip deleted ones 8626 if (listeners->get(i)->IsUndefined(isolate)) continue; // skip deleted ones
8614 i::FixedArray* listener = i::FixedArray::cast(listeners->get(i)); 8627 i::FixedArray* listener = i::FixedArray::cast(listeners->get(i));
8615 i::Foreign* callback_obj = i::Foreign::cast(listener->get(0)); 8628 i::Foreign* callback_obj = i::Foreign::cast(listener->get(0));
8616 if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) { 8629 if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) {
8617 listeners->set(i, isolate->heap()->undefined_value()); 8630 listeners->set(i, isolate->heap()->undefined_value());
8618 } 8631 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
8780 8793
8781 8794
8782 String::Value::~Value() { 8795 String::Value::~Value() {
8783 i::DeleteArray(str_); 8796 i::DeleteArray(str_);
8784 } 8797 }
8785 8798
8786 #define DEFINE_ERROR(NAME, name) \ 8799 #define DEFINE_ERROR(NAME, name) \
8787 Local<Value> Exception::NAME(v8::Local<v8::String> raw_message) { \ 8800 Local<Value> Exception::NAME(v8::Local<v8::String> raw_message) { \
8788 i::Isolate* isolate = i::Isolate::Current(); \ 8801 i::Isolate* isolate = i::Isolate::Current(); \
8789 LOG_API(isolate, NAME, New); \ 8802 LOG_API(isolate, NAME, New); \
8790 ENTER_V8(isolate); \ 8803 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); \
8791 i::Object* error; \ 8804 i::Object* error; \
8792 { \ 8805 { \
8793 i::HandleScope scope(isolate); \ 8806 i::HandleScope scope(isolate); \
8794 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); \ 8807 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); \
8795 i::Handle<i::JSFunction> constructor = isolate->name##_function(); \ 8808 i::Handle<i::JSFunction> constructor = isolate->name##_function(); \
8796 error = *isolate->factory()->NewError(constructor, message); \ 8809 error = *isolate->factory()->NewError(constructor, message); \
8797 } \ 8810 } \
8798 i::Handle<i::Object> result(error, isolate); \ 8811 i::Handle<i::Object> result(error, isolate); \
8799 return Utils::ToLocal(result); \ 8812 return Utils::ToLocal(result); \
8800 } 8813 }
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
10023 Address callback_address = 10036 Address callback_address =
10024 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10037 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10025 VMState<EXTERNAL> state(isolate); 10038 VMState<EXTERNAL> state(isolate);
10026 ExternalCallbackScope call_scope(isolate, callback_address); 10039 ExternalCallbackScope call_scope(isolate, callback_address);
10027 callback(info); 10040 callback(info);
10028 } 10041 }
10029 10042
10030 10043
10031 } // namespace internal 10044 } // namespace internal
10032 } // namespace v8 10045 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698