| OLD | NEW |
| 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 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 } | 993 } |
| 994 } | 994 } |
| 995 } | 995 } |
| 996 } | 996 } |
| 997 | 997 |
| 998 | 998 |
| 999 // ------------------------------------------------------------------------ | 999 // ------------------------------------------------------------------------ |
| 1000 // StubCompiler implementation. | 1000 // StubCompiler implementation. |
| 1001 | 1001 |
| 1002 | 1002 |
| 1003 RUNTIME_FUNCTION(MaybeObject*, LoadCallbackProperty) { | |
| 1004 ASSERT(args[0]->IsJSObject()); | |
| 1005 ASSERT(args[1]->IsJSObject()); | |
| 1006 ASSERT(args[3]->IsSmi()); | |
| 1007 AccessorInfo* callback = AccessorInfo::cast(args[4]); | |
| 1008 Address getter_address = v8::ToCData<Address>(callback->getter()); | |
| 1009 v8::AccessorGetter fun = FUNCTION_CAST<v8::AccessorGetter>(getter_address); | |
| 1010 ASSERT(fun != NULL); | |
| 1011 ASSERT(callback->IsCompatibleReceiver(args[0])); | |
| 1012 v8::AccessorInfo info(&args[0]); | |
| 1013 HandleScope scope(isolate); | |
| 1014 v8::Handle<v8::Value> result; | |
| 1015 { | |
| 1016 // Leaving JavaScript. | |
| 1017 VMState state(isolate, EXTERNAL); | |
| 1018 ExternalCallbackScope call_scope(isolate, getter_address); | |
| 1019 result = fun(v8::Utils::ToLocal(args.at<String>(5)), info); | |
| 1020 } | |
| 1021 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | |
| 1022 if (result.IsEmpty()) return HEAP->undefined_value(); | |
| 1023 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); | |
| 1024 result_internal->VerifyApiCallResultType(); | |
| 1025 return *result_internal; | |
| 1026 } | |
| 1027 | |
| 1028 | |
| 1029 RUNTIME_FUNCTION(MaybeObject*, StoreCallbackProperty) { | 1003 RUNTIME_FUNCTION(MaybeObject*, StoreCallbackProperty) { |
| 1030 JSObject* recv = JSObject::cast(args[0]); | 1004 JSObject* recv = JSObject::cast(args[0]); |
| 1031 AccessorInfo* callback = AccessorInfo::cast(args[1]); | 1005 AccessorInfo* callback = AccessorInfo::cast(args[1]); |
| 1032 Address setter_address = v8::ToCData<Address>(callback->setter()); | 1006 Address setter_address = v8::ToCData<Address>(callback->setter()); |
| 1033 v8::AccessorSetter fun = FUNCTION_CAST<v8::AccessorSetter>(setter_address); | 1007 v8::AccessorSetter fun = FUNCTION_CAST<v8::AccessorSetter>(setter_address); |
| 1034 ASSERT(fun != NULL); | 1008 ASSERT(fun != NULL); |
| 1035 ASSERT(callback->IsCompatibleReceiver(recv)); | 1009 ASSERT(callback->IsCompatibleReceiver(recv)); |
| 1036 Handle<String> name = args.at<String>(2); | 1010 Handle<String> name = args.at<String>(2); |
| 1037 Handle<Object> value = args.at<Object>(3); | 1011 Handle<Object> value = args.at<Object>(3); |
| 1038 HandleScope scope(isolate); | 1012 HandleScope scope(isolate); |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 } | 1364 } |
| 1391 | 1365 |
| 1392 | 1366 |
| 1393 #define __ ACCESS_MASM(masm()) | 1367 #define __ ACCESS_MASM(masm()) |
| 1394 | 1368 |
| 1395 | 1369 |
| 1396 Handle<Code> BaseLoadStubCompiler::CompileLoadField(Handle<JSObject> object, | 1370 Handle<Code> BaseLoadStubCompiler::CompileLoadField(Handle<JSObject> object, |
| 1397 Handle<JSObject> holder, | 1371 Handle<JSObject> holder, |
| 1398 Handle<String> name, | 1372 Handle<String> name, |
| 1399 PropertyIndex index) { | 1373 PropertyIndex index) { |
| 1400 Label miss; | 1374 Label success; |
| 1401 | 1375 Register reg = |
| 1402 GenerateNameCheck(name, this->name(), &miss); | 1376 HandlerFrontend(object, receiver(), holder, name, &success, true); |
| 1403 GenerateLoadField(object, holder, receiver(), | 1377 __ bind(&success); |
| 1404 scratch1(), scratch2(), scratch3(), | 1378 GenerateLoadField(reg, holder, index); |
| 1405 index, name, &miss); | |
| 1406 __ bind(&miss); | |
| 1407 GenerateLoadMiss(masm(), kind()); | |
| 1408 | 1379 |
| 1409 // Return the generated code. | 1380 // Return the generated code. |
| 1410 return GetCode(Code::FIELD, name); | 1381 return GetCode(Code::FIELD, name); |
| 1411 } | 1382 } |
| 1412 | 1383 |
| 1413 | 1384 |
| 1385 Handle<Code> BaseLoadStubCompiler::CompileLoadConstant( |
| 1386 Handle<JSObject> object, |
| 1387 Handle<JSObject> holder, |
| 1388 Handle<String> name, |
| 1389 Handle<JSFunction> value) { |
| 1390 Label success; |
| 1391 HandlerFrontend(object, receiver(), holder, name, &success, true); |
| 1392 __ bind(&success); |
| 1393 GenerateLoadConstant(value); |
| 1394 |
| 1395 // Return the generated code. |
| 1396 return GetCode(Code::CONSTANT_FUNCTION, name); |
| 1397 } |
| 1398 |
| 1399 |
| 1414 Handle<Code> BaseLoadStubCompiler::CompileLoadCallback( | 1400 Handle<Code> BaseLoadStubCompiler::CompileLoadCallback( |
| 1415 Handle<JSObject> object, | 1401 Handle<JSObject> object, |
| 1416 Handle<JSObject> holder, | 1402 Handle<JSObject> holder, |
| 1417 Handle<String> name, | 1403 Handle<String> name, |
| 1418 Handle<AccessorInfo> callback) { | 1404 Handle<AccessorInfo> callback) { |
| 1419 Label miss; | 1405 Label success; |
| 1420 | 1406 |
| 1421 GenerateNameCheck(name, this->name(), &miss); | 1407 Register reg = CallbackHandlerFrontend( |
| 1422 GenerateLoadCallback(object, holder, receiver(), this->name(), | 1408 object, receiver(), holder, name, &success, true, callback); |
| 1423 scratch1(), scratch2(), scratch3(), scratch4(), | 1409 __ bind(&success); |
| 1424 callback, name, &miss); | 1410 GenerateLoadCallback(reg, callback); |
| 1425 __ bind(&miss); | |
| 1426 GenerateLoadMiss(masm(), kind()); | |
| 1427 | 1411 |
| 1428 // Return the generated code. | 1412 // Return the generated code. |
| 1429 return GetCode(Code::CALLBACKS, name); | 1413 return GetCode(Code::CALLBACKS, name); |
| 1430 } | 1414 } |
| 1431 | 1415 |
| 1432 | 1416 |
| 1433 Handle<Code> BaseLoadStubCompiler::CompileLoadConstant( | |
| 1434 Handle<JSObject> object, | |
| 1435 Handle<JSObject> holder, | |
| 1436 Handle<String> name, | |
| 1437 Handle<JSFunction> value) { | |
| 1438 Label miss; | |
| 1439 | |
| 1440 GenerateNameCheck(name, this->name(), &miss); | |
| 1441 GenerateLoadConstant(object, holder, receiver(), | |
| 1442 scratch1(), scratch2(), scratch3(), | |
| 1443 value, name, &miss); | |
| 1444 __ bind(&miss); | |
| 1445 GenerateLoadMiss(masm(), kind()); | |
| 1446 | |
| 1447 // Return the generated code. | |
| 1448 return GetCode(Code::CONSTANT_FUNCTION, name); | |
| 1449 } | |
| 1450 | |
| 1451 | |
| 1452 Handle<Code> BaseLoadStubCompiler::CompileLoadInterceptor( | 1417 Handle<Code> BaseLoadStubCompiler::CompileLoadInterceptor( |
| 1453 Handle<JSObject> object, | 1418 Handle<JSObject> object, |
| 1454 Handle<JSObject> holder, | 1419 Handle<JSObject> holder, |
| 1455 Handle<String> name) { | 1420 Handle<String> name) { |
| 1456 Label miss; | 1421 Label success; |
| 1457 | 1422 |
| 1458 LookupResult lookup(isolate()); | 1423 LookupResult lookup(isolate()); |
| 1459 LookupPostInterceptor(holder, name, &lookup); | 1424 LookupPostInterceptor(holder, name, &lookup); |
| 1460 | 1425 |
| 1461 GenerateNameCheck(name, this->name(), &miss); | 1426 Register reg = |
| 1427 HandlerFrontend(object, receiver(), holder, name, &success, true); |
| 1428 __ bind(&success); |
| 1462 // TODO(368): Compile in the whole chain: all the interceptors in | 1429 // TODO(368): Compile in the whole chain: all the interceptors in |
| 1463 // prototypes and ultimate answer. | 1430 // prototypes and ultimate answer. |
| 1464 GenerateLoadInterceptor(object, holder, &lookup, receiver(), this->name(), | 1431 GenerateLoadInterceptor(reg, object, holder, &lookup, name); |
| 1465 scratch1(), scratch2(), scratch3(), | |
| 1466 name, &miss); | |
| 1467 | |
| 1468 __ bind(&miss); | |
| 1469 GenerateLoadMiss(masm(), kind()); | |
| 1470 | 1432 |
| 1471 // Return the generated code. | 1433 // Return the generated code. |
| 1472 return GetCode(Code::INTERCEPTOR, name); | 1434 return GetCode(Code::INTERCEPTOR, name); |
| 1473 } | 1435 } |
| 1474 | 1436 |
| 1475 | 1437 |
| 1476 #undef __ | 1438 #undef __ |
| 1477 | 1439 |
| 1478 | 1440 |
| 1479 Handle<Code> LoadStubCompiler::GetCode(Code::StubType type, | 1441 Handle<Code> LoadStubCompiler::GetCode(Code::StubType type, |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1762 Handle<FunctionTemplateInfo>( | 1724 Handle<FunctionTemplateInfo>( |
| 1763 FunctionTemplateInfo::cast(signature->receiver())); | 1725 FunctionTemplateInfo::cast(signature->receiver())); |
| 1764 } | 1726 } |
| 1765 } | 1727 } |
| 1766 | 1728 |
| 1767 is_simple_api_call_ = true; | 1729 is_simple_api_call_ = true; |
| 1768 } | 1730 } |
| 1769 | 1731 |
| 1770 | 1732 |
| 1771 } } // namespace v8::internal | 1733 } } // namespace v8::internal |
| OLD | NEW |