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

Side by Side Diff: src/builtins.cc

Issue 12494012: new style of property/function callbacks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 7 years, 8 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
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 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); 1301 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data);
1302 Object* callback_obj = call_data->callback(); 1302 Object* callback_obj = call_data->callback();
1303 v8::InvocationCallback callback = 1303 v8::InvocationCallback callback =
1304 v8::ToCData<v8::InvocationCallback>(callback_obj); 1304 v8::ToCData<v8::InvocationCallback>(callback_obj);
1305 Object* data_obj = call_data->data(); 1305 Object* data_obj = call_data->data();
1306 Object* result; 1306 Object* result;
1307 1307
1308 LOG(isolate, ApiObjectAccess("call", JSObject::cast(*args.receiver()))); 1308 LOG(isolate, ApiObjectAccess("call", JSObject::cast(*args.receiver())));
1309 ASSERT(raw_holder->IsJSObject()); 1309 ASSERT(raw_holder->IsJSObject());
1310 1310
1311 CustomArguments custom(isolate); 1311 FunctionCallbackArguments custom(isolate, data_obj, *function, raw_holder);
1312 v8::ImplementationUtilities::PrepareArgumentsData(custom.end(), 1312 v8::Arguments new_args = custom.NewArguments(
1313 isolate, data_obj, *function, raw_holder);
1314
1315 v8::Arguments new_args = v8::ImplementationUtilities::NewArguments(
1316 custom.end(),
1317 &args[0] - 1, 1313 &args[0] - 1,
1318 args.length() - 1, 1314 args.length() - 1,
1319 is_construct); 1315 is_construct);
1320 1316
1321 v8::Handle<v8::Value> value; 1317 v8::Handle<v8::Value> value;
1322 { 1318 {
1323 // Leaving JavaScript. 1319 // Leaving JavaScript.
1324 VMState<EXTERNAL> state(isolate); 1320 VMState<EXTERNAL> state(isolate);
1325 ExternalCallbackScope call_scope(isolate, 1321 ExternalCallbackScope call_scope(isolate,
1326 v8::ToCData<Address>(callback_obj)); 1322 v8::ToCData<Address>(callback_obj));
1327 value = callback(new_args); 1323 value = custom.GetCallbackResult(isolate, callback, callback(new_args));
1328 } 1324 }
1329 if (value.IsEmpty()) { 1325 if (value.IsEmpty()) {
1330 result = heap->undefined_value(); 1326 result = heap->undefined_value();
1331 } else { 1327 } else {
1332 result = *reinterpret_cast<Object**>(*value); 1328 result = *reinterpret_cast<Object**>(*value);
1333 result->VerifyApiCallResultType(); 1329 result->VerifyApiCallResultType();
1334 } 1330 }
1335 1331
1336 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 1332 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
1337 if (!is_construct || result->IsJSObject()) return result; 1333 if (!is_construct || result->IsJSObject()) return result;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 Object* callback_obj = call_data->callback(); 1376 Object* callback_obj = call_data->callback();
1381 v8::InvocationCallback callback = 1377 v8::InvocationCallback callback =
1382 v8::ToCData<v8::InvocationCallback>(callback_obj); 1378 v8::ToCData<v8::InvocationCallback>(callback_obj);
1383 1379
1384 // Get the data for the call and perform the callback. 1380 // Get the data for the call and perform the callback.
1385 Object* result; 1381 Object* result;
1386 { 1382 {
1387 HandleScope scope(isolate); 1383 HandleScope scope(isolate);
1388 LOG(isolate, ApiObjectAccess("call non-function", obj)); 1384 LOG(isolate, ApiObjectAccess("call non-function", obj));
1389 1385
1390 CustomArguments custom(isolate); 1386 FunctionCallbackArguments
1391 v8::ImplementationUtilities::PrepareArgumentsData(custom.end(), 1387 custom(isolate, call_data->data(), constructor, obj);
1392 isolate, call_data->data(), constructor, obj); 1388 v8::Arguments new_args = custom.NewArguments(
1393 v8::Arguments new_args = v8::ImplementationUtilities::NewArguments(
1394 custom.end(),
1395 &args[0] - 1, 1389 &args[0] - 1,
1396 args.length() - 1, 1390 args.length() - 1,
1397 is_construct_call); 1391 is_construct_call);
1398 v8::Handle<v8::Value> value; 1392 v8::Handle<v8::Value> value;
1399 { 1393 {
1400 // Leaving JavaScript. 1394 // Leaving JavaScript.
1401 VMState<EXTERNAL> state(isolate); 1395 VMState<EXTERNAL> state(isolate);
1402 ExternalCallbackScope call_scope(isolate, 1396 ExternalCallbackScope call_scope(isolate,
1403 v8::ToCData<Address>(callback_obj)); 1397 v8::ToCData<Address>(callback_obj));
1404 value = callback(new_args); 1398 value = custom.GetCallbackResult(isolate, callback, callback(new_args));
1405 } 1399 }
1406 if (value.IsEmpty()) { 1400 if (value.IsEmpty()) {
1407 result = heap->undefined_value(); 1401 result = heap->undefined_value();
1408 } else { 1402 } else {
1409 result = *reinterpret_cast<Object**>(*value); 1403 result = *reinterpret_cast<Object**>(*value);
1410 result->VerifyApiCallResultType(); 1404 result->VerifyApiCallResultType();
1411 } 1405 }
1412 } 1406 }
1413 // Check for exceptions and return result. 1407 // Check for exceptions and return result.
1414 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 1408 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 return Handle<Code>(code_address); \ 1861 return Handle<Code>(code_address); \
1868 } 1862 }
1869 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 1863 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
1870 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 1864 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
1871 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 1865 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
1872 #undef DEFINE_BUILTIN_ACCESSOR_C 1866 #undef DEFINE_BUILTIN_ACCESSOR_C
1873 #undef DEFINE_BUILTIN_ACCESSOR_A 1867 #undef DEFINE_BUILTIN_ACCESSOR_A
1874 1868
1875 1869
1876 } } // namespace v8::internal 1870 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arguments.h ('k') | src/handles.cc » ('j') | src/x64/macro-assembler-x64.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698