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

Side by Side Diff: src/api.cc

Issue 15793007: Cutover v8 to use new style callbacks internally (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/accessors.cc ('k') | src/arguments.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 Callback callback_in, 1207 Callback callback_in,
1208 v8::Handle<Value> data) { 1208 v8::Handle<Value> data) {
1209 i::Isolate* isolate = Utils::OpenHandle(function_template)->GetIsolate(); 1209 i::Isolate* isolate = Utils::OpenHandle(function_template)->GetIsolate();
1210 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetCallHandler()")) return; 1210 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetCallHandler()")) return;
1211 ENTER_V8(isolate); 1211 ENTER_V8(isolate);
1212 i::HandleScope scope(isolate); 1212 i::HandleScope scope(isolate);
1213 i::Handle<i::Struct> struct_obj = 1213 i::Handle<i::Struct> struct_obj =
1214 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); 1214 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE);
1215 i::Handle<i::CallHandlerInfo> obj = 1215 i::Handle<i::CallHandlerInfo> obj =
1216 i::Handle<i::CallHandlerInfo>::cast(struct_obj); 1216 i::Handle<i::CallHandlerInfo>::cast(struct_obj);
1217 InvocationCallback callback = 1217 FunctionCallback callback =
1218 i::CallbackTable::Register(isolate, callback_in); 1218 i::CallbackTable::Register(isolate, callback_in);
1219 SET_FIELD_WRAPPED(obj, set_callback, callback); 1219 SET_FIELD_WRAPPED(obj, set_callback, callback);
1220 if (data.IsEmpty()) data = v8::Undefined(); 1220 if (data.IsEmpty()) data = v8::Undefined();
1221 obj->set_data(*Utils::OpenHandle(*data)); 1221 obj->set_data(*Utils::OpenHandle(*data));
1222 Utils::OpenHandle(function_template)->set_call_code(*obj); 1222 Utils::OpenHandle(function_template)->set_call_code(*obj);
1223 } 1223 }
1224 1224
1225 void FunctionTemplate::SetCallHandler(InvocationCallback callback, 1225 void FunctionTemplate::SetCallHandler(InvocationCallback callback,
1226 v8::Handle<Value> data) { 1226 v8::Handle<Value> data) {
1227 FunctionTemplateSetCallHandler(this, callback, data); 1227 FunctionTemplateSetCallHandler(this, callback, data);
(...skipping 27 matching lines...) Expand all
1255 v8::Handle<String> name, 1255 v8::Handle<String> name,
1256 Getter getter_in, 1256 Getter getter_in,
1257 Setter setter_in, 1257 Setter setter_in,
1258 v8::Handle<Value> data, 1258 v8::Handle<Value> data,
1259 v8::AccessControl settings, 1259 v8::AccessControl settings,
1260 v8::PropertyAttribute attributes, 1260 v8::PropertyAttribute attributes,
1261 v8::Handle<AccessorSignature> signature) { 1261 v8::Handle<AccessorSignature> signature) {
1262 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate(); 1262 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate();
1263 i::Handle<i::ExecutableAccessorInfo> obj = 1263 i::Handle<i::ExecutableAccessorInfo> obj =
1264 isolate->factory()->NewExecutableAccessorInfo(); 1264 isolate->factory()->NewExecutableAccessorInfo();
1265 AccessorGetter getter = i::CallbackTable::Register(isolate, getter_in); 1265 AccessorGetterCallback getter =
1266 i::CallbackTable::Register(isolate, getter_in);
1266 SET_FIELD_WRAPPED(obj, set_getter, getter); 1267 SET_FIELD_WRAPPED(obj, set_getter, getter);
1267 AccessorSetter setter = i::CallbackTable::Register(isolate, setter_in); 1268 AccessorSetterCallback setter =
1269 i::CallbackTable::Register(isolate, setter_in);
1268 SET_FIELD_WRAPPED(obj, set_setter, setter); 1270 SET_FIELD_WRAPPED(obj, set_setter, setter);
1269 if (data.IsEmpty()) data = v8::Undefined(); 1271 if (data.IsEmpty()) data = v8::Undefined();
1270 obj->set_data(*Utils::OpenHandle(*data)); 1272 obj->set_data(*Utils::OpenHandle(*data));
1271 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); 1273 return SetAccessorInfoProperties(obj, name, settings, attributes, signature);
1272 } 1274 }
1273 1275
1274 1276
1275 static i::Handle<i::AccessorInfo> MakeAccessorInfo( 1277 static i::Handle<i::AccessorInfo> MakeAccessorInfo(
1276 v8::Handle<String> name, 1278 v8::Handle<String> name,
1277 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor, 1279 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 "v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) { 1362 "v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) {
1361 return; 1363 return;
1362 } 1364 }
1363 ENTER_V8(isolate); 1365 ENTER_V8(isolate);
1364 i::HandleScope scope(isolate); 1366 i::HandleScope scope(isolate);
1365 i::Handle<i::Struct> struct_obj = 1367 i::Handle<i::Struct> struct_obj =
1366 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); 1368 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE);
1367 i::Handle<i::InterceptorInfo> obj = 1369 i::Handle<i::InterceptorInfo> obj =
1368 i::Handle<i::InterceptorInfo>::cast(struct_obj); 1370 i::Handle<i::InterceptorInfo>::cast(struct_obj);
1369 1371
1370 NamedPropertyGetter getter = i::CallbackTable::Register(isolate, getter_in); 1372 NamedPropertyGetterCallback getter =
1373 i::CallbackTable::Register(isolate, getter_in);
1371 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); 1374 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
1372 NamedPropertySetter setter = i::CallbackTable::Register(isolate, setter_in); 1375 NamedPropertySetterCallback setter =
1376 i::CallbackTable::Register(isolate, setter_in);
1373 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); 1377 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
1374 NamedPropertyQuery query = i::CallbackTable::Register(isolate, query_in); 1378 NamedPropertyQueryCallback query =
1379 i::CallbackTable::Register(isolate, query_in);
1375 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); 1380 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query);
1376 NamedPropertyDeleter remover = 1381 NamedPropertyDeleterCallback remover =
1377 i::CallbackTable::Register(isolate, remover_in); 1382 i::CallbackTable::Register(isolate, remover_in);
1378 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); 1383 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover);
1379 NamedPropertyEnumerator enumerator = 1384 NamedPropertyEnumeratorCallback enumerator =
1380 i::CallbackTable::Register(isolate, enumerator_in); 1385 i::CallbackTable::Register(isolate, enumerator_in);
1381 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); 1386 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator);
1382 1387
1383 if (data.IsEmpty()) data = v8::Undefined(); 1388 if (data.IsEmpty()) data = v8::Undefined();
1384 obj->set_data(*Utils::OpenHandle(*data)); 1389 obj->set_data(*Utils::OpenHandle(*data));
1385 function_template->set_named_property_handler(*obj); 1390 function_template->set_named_property_handler(*obj);
1386 } 1391 }
1387 1392
1388 1393
1389 template< 1394 template<
(...skipping 15 matching lines...) Expand all
1405 "v8::FunctionTemplate::SetIndexedInstancePropertyHandler()")) { 1410 "v8::FunctionTemplate::SetIndexedInstancePropertyHandler()")) {
1406 return; 1411 return;
1407 } 1412 }
1408 ENTER_V8(isolate); 1413 ENTER_V8(isolate);
1409 i::HandleScope scope(isolate); 1414 i::HandleScope scope(isolate);
1410 i::Handle<i::Struct> struct_obj = 1415 i::Handle<i::Struct> struct_obj =
1411 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); 1416 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE);
1412 i::Handle<i::InterceptorInfo> obj = 1417 i::Handle<i::InterceptorInfo> obj =
1413 i::Handle<i::InterceptorInfo>::cast(struct_obj); 1418 i::Handle<i::InterceptorInfo>::cast(struct_obj);
1414 1419
1415 IndexedPropertyGetter getter = 1420 IndexedPropertyGetterCallback getter =
1416 i::CallbackTable::Register(isolate, getter_in); 1421 i::CallbackTable::Register(isolate, getter_in);
1417 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); 1422 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
1418 IndexedPropertySetter setter = 1423 IndexedPropertySetterCallback setter =
1419 i::CallbackTable::Register(isolate, setter_in); 1424 i::CallbackTable::Register(isolate, setter_in);
1420 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); 1425 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
1421 IndexedPropertyQuery query = i::CallbackTable::Register(isolate, query_in); 1426 IndexedPropertyQueryCallback query =
1427 i::CallbackTable::Register(isolate, query_in);
1422 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); 1428 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query);
1423 IndexedPropertyDeleter remover = 1429 IndexedPropertyDeleterCallback remover =
1424 i::CallbackTable::Register(isolate, remover_in); 1430 i::CallbackTable::Register(isolate, remover_in);
1425 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); 1431 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover);
1426 IndexedPropertyEnumerator enumerator = 1432 IndexedPropertyEnumeratorCallback enumerator =
1427 i::CallbackTable::Register(isolate, enumerator_in); 1433 i::CallbackTable::Register(isolate, enumerator_in);
1428 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); 1434 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator);
1429 1435
1430 if (data.IsEmpty()) data = v8::Undefined(); 1436 if (data.IsEmpty()) data = v8::Undefined();
1431 obj->set_data(*Utils::OpenHandle(*data)); 1437 obj->set_data(*Utils::OpenHandle(*data));
1432 function_template->set_indexed_property_handler(*obj); 1438 function_template->set_indexed_property_handler(*obj);
1433 } 1439 }
1434 1440
1435 1441
1436 template<typename Callback> 1442 template<typename Callback>
1437 static void SetInstanceCallAsFunctionHandler( 1443 static void SetInstanceCallAsFunctionHandler(
1438 i::Handle<i::FunctionTemplateInfo> function_template, 1444 i::Handle<i::FunctionTemplateInfo> function_template,
1439 Callback callback_in, 1445 Callback callback_in,
1440 Handle<Value> data) { 1446 Handle<Value> data) {
1441 i::Isolate* isolate = function_template->GetIsolate(); 1447 i::Isolate* isolate = function_template->GetIsolate();
1442 if (IsDeadCheck(isolate, 1448 if (IsDeadCheck(isolate,
1443 "v8::FunctionTemplate::SetInstanceCallAsFunctionHandler()")) { 1449 "v8::FunctionTemplate::SetInstanceCallAsFunctionHandler()")) {
1444 return; 1450 return;
1445 } 1451 }
1446 ENTER_V8(isolate); 1452 ENTER_V8(isolate);
1447 i::HandleScope scope(isolate); 1453 i::HandleScope scope(isolate);
1448 i::Handle<i::Struct> struct_obj = 1454 i::Handle<i::Struct> struct_obj =
1449 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); 1455 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE);
1450 i::Handle<i::CallHandlerInfo> obj = 1456 i::Handle<i::CallHandlerInfo> obj =
1451 i::Handle<i::CallHandlerInfo>::cast(struct_obj); 1457 i::Handle<i::CallHandlerInfo>::cast(struct_obj);
1452 InvocationCallback callback = 1458 FunctionCallback callback =
1453 i::CallbackTable::Register(isolate, callback_in); 1459 i::CallbackTable::Register(isolate, callback_in);
1454 SET_FIELD_WRAPPED(obj, set_callback, callback); 1460 SET_FIELD_WRAPPED(obj, set_callback, callback);
1455 if (data.IsEmpty()) data = v8::Undefined(); 1461 if (data.IsEmpty()) data = v8::Undefined();
1456 obj->set_data(*Utils::OpenHandle(*data)); 1462 obj->set_data(*Utils::OpenHandle(*data));
1457 function_template->set_instance_call_handler(*obj); 1463 function_template->set_instance_call_handler(*obj);
1458 } 1464 }
1459 1465
1460 1466
1461 // --- O b j e c t T e m p l a t e --- 1467 // --- O b j e c t T e m p l a t e ---
1462 1468
(...skipping 6386 matching lines...) Expand 10 before | Expand all | Expand 10 after
7849 7855
7850 v->VisitPointers(blocks_.first(), first_block_limit_); 7856 v->VisitPointers(blocks_.first(), first_block_limit_);
7851 7857
7852 for (int i = 1; i < blocks_.length(); i++) { 7858 for (int i = 1; i < blocks_.length(); i++) {
7853 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 7859 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
7854 } 7860 }
7855 } 7861 }
7856 7862
7857 7863
7858 } } // namespace v8::internal 7864 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/arguments.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698