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

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: make arm look like other architectures Created 7 years, 7 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/arm/stub-cache-arm.cc ('k') | src/handles.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // 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 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); 1310 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data);
1311 Object* callback_obj = call_data->callback(); 1311 Object* callback_obj = call_data->callback();
1312 v8::InvocationCallback callback = 1312 v8::InvocationCallback callback =
1313 v8::ToCData<v8::InvocationCallback>(callback_obj); 1313 v8::ToCData<v8::InvocationCallback>(callback_obj);
1314 Object* data_obj = call_data->data(); 1314 Object* data_obj = call_data->data();
1315 Object* result; 1315 Object* result;
1316 1316
1317 LOG(isolate, ApiObjectAccess("call", JSObject::cast(*args.receiver()))); 1317 LOG(isolate, ApiObjectAccess("call", JSObject::cast(*args.receiver())));
1318 ASSERT(raw_holder->IsJSObject()); 1318 ASSERT(raw_holder->IsJSObject());
1319 1319
1320 CustomArguments custom(isolate); 1320 FunctionCallbackArguments custom(isolate,
1321 v8::ImplementationUtilities::PrepareArgumentsData(custom.end(), 1321 data_obj,
1322 isolate, data_obj, *function, raw_holder); 1322 *function,
1323 1323 raw_holder,
1324 v8::Arguments new_args = v8::ImplementationUtilities::NewArguments( 1324 &args[0] - 1,
1325 custom.end(), 1325 args.length() - 1,
1326 &args[0] - 1, 1326 is_construct);
1327 args.length() - 1,
1328 is_construct);
1329 1327
1330 v8::Handle<v8::Value> value; 1328 v8::Handle<v8::Value> value;
1331 { 1329 {
1332 // Leaving JavaScript. 1330 // Leaving JavaScript.
1333 VMState<EXTERNAL> state(isolate); 1331 VMState<EXTERNAL> state(isolate);
1334 ExternalCallbackScope call_scope(isolate, 1332 ExternalCallbackScope call_scope(isolate,
1335 v8::ToCData<Address>(callback_obj)); 1333 v8::ToCData<Address>(callback_obj));
1336 value = callback(new_args); 1334 value = custom.Call(callback);
1337 } 1335 }
1338 if (value.IsEmpty()) { 1336 if (value.IsEmpty()) {
1339 result = heap->undefined_value(); 1337 result = heap->undefined_value();
1340 } else { 1338 } else {
1341 result = *reinterpret_cast<Object**>(*value); 1339 result = *reinterpret_cast<Object**>(*value);
1342 result->VerifyApiCallResultType(); 1340 result->VerifyApiCallResultType();
1343 } 1341 }
1344 1342
1345 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 1343 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
1346 if (!is_construct || result->IsJSObject()) return result; 1344 if (!is_construct || result->IsJSObject()) return result;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 Object* callback_obj = call_data->callback(); 1387 Object* callback_obj = call_data->callback();
1390 v8::InvocationCallback callback = 1388 v8::InvocationCallback callback =
1391 v8::ToCData<v8::InvocationCallback>(callback_obj); 1389 v8::ToCData<v8::InvocationCallback>(callback_obj);
1392 1390
1393 // Get the data for the call and perform the callback. 1391 // Get the data for the call and perform the callback.
1394 Object* result; 1392 Object* result;
1395 { 1393 {
1396 HandleScope scope(isolate); 1394 HandleScope scope(isolate);
1397 LOG(isolate, ApiObjectAccess("call non-function", obj)); 1395 LOG(isolate, ApiObjectAccess("call non-function", obj));
1398 1396
1399 CustomArguments custom(isolate); 1397 FunctionCallbackArguments custom(isolate,
1400 v8::ImplementationUtilities::PrepareArgumentsData(custom.end(), 1398 call_data->data(),
1401 isolate, call_data->data(), constructor, obj); 1399 constructor,
1402 v8::Arguments new_args = v8::ImplementationUtilities::NewArguments( 1400 obj,
1403 custom.end(), 1401 &args[0] - 1,
1404 &args[0] - 1, 1402 args.length() - 1,
1405 args.length() - 1, 1403 is_construct_call);
1406 is_construct_call);
1407 v8::Handle<v8::Value> value; 1404 v8::Handle<v8::Value> value;
1408 { 1405 {
1409 // Leaving JavaScript. 1406 // Leaving JavaScript.
1410 VMState<EXTERNAL> state(isolate); 1407 VMState<EXTERNAL> state(isolate);
1411 ExternalCallbackScope call_scope(isolate, 1408 ExternalCallbackScope call_scope(isolate,
1412 v8::ToCData<Address>(callback_obj)); 1409 v8::ToCData<Address>(callback_obj));
1413 value = callback(new_args); 1410 value = custom.Call(callback);
1414 } 1411 }
1415 if (value.IsEmpty()) { 1412 if (value.IsEmpty()) {
1416 result = heap->undefined_value(); 1413 result = heap->undefined_value();
1417 } else { 1414 } else {
1418 result = *reinterpret_cast<Object**>(*value); 1415 result = *reinterpret_cast<Object**>(*value);
1419 result->VerifyApiCallResultType(); 1416 result->VerifyApiCallResultType();
1420 } 1417 }
1421 } 1418 }
1422 // Check for exceptions and return result. 1419 // Check for exceptions and return result.
1423 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 1420 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 return Handle<Code>(code_address); \ 1883 return Handle<Code>(code_address); \
1887 } 1884 }
1888 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 1885 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
1889 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 1886 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
1890 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 1887 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
1891 #undef DEFINE_BUILTIN_ACCESSOR_C 1888 #undef DEFINE_BUILTIN_ACCESSOR_C
1892 #undef DEFINE_BUILTIN_ACCESSOR_A 1889 #undef DEFINE_BUILTIN_ACCESSOR_A
1893 1890
1894 1891
1895 } } // namespace v8::internal 1892 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698