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 = GenerateHandlerFrontend( |
1402 GenerateNameCheck(name, this->name(), &miss); | 1376 object, receiver(), holder, name, |
1403 GenerateLoadField(object, holder, receiver(), | 1377 &success, Handle<AccessorInfo>::null(), true); |
1404 scratch1(), scratch2(), scratch3(), | 1378 __ bind(&success); |
1405 index, name, &miss); | 1379 GenerateLoadField(reg, holder, index); |
1406 __ bind(&miss); | |
1407 GenerateLoadMiss(masm(), kind()); | |
1408 | 1380 |
1409 // Return the generated code. | 1381 // Return the generated code. |
1410 return GetCode(Code::FIELD, name); | 1382 return GetCode(Code::FIELD, name); |
1411 } | 1383 } |
1412 | 1384 |
1413 | 1385 |
| 1386 Handle<Code> BaseLoadStubCompiler::CompileLoadConstant( |
| 1387 Handle<JSObject> object, |
| 1388 Handle<JSObject> holder, |
| 1389 Handle<String> name, |
| 1390 Handle<JSFunction> value) { |
| 1391 Label success; |
| 1392 GenerateHandlerFrontend(object, receiver(), holder, name, |
| 1393 &success, Handle<AccessorInfo>::null(), true); |
| 1394 __ bind(&success); |
| 1395 GenerateLoadConstant(value); |
| 1396 |
| 1397 // Return the generated code. |
| 1398 return GetCode(Code::CONSTANT_FUNCTION, name); |
| 1399 } |
| 1400 |
| 1401 |
1414 Handle<Code> BaseLoadStubCompiler::CompileLoadCallback( | 1402 Handle<Code> BaseLoadStubCompiler::CompileLoadCallback( |
1415 Handle<JSObject> object, | 1403 Handle<JSObject> object, |
1416 Handle<JSObject> holder, | 1404 Handle<JSObject> holder, |
1417 Handle<String> name, | 1405 Handle<String> name, |
1418 Handle<AccessorInfo> callback) { | 1406 Handle<AccessorInfo> callback) { |
1419 Label miss; | 1407 Label success; |
1420 | 1408 |
1421 GenerateNameCheck(name, this->name(), &miss); | 1409 Register reg = GenerateHandlerFrontend(object, receiver(), holder, name, |
1422 GenerateLoadCallback(object, holder, receiver(), this->name(), | 1410 &success, callback, true); |
1423 scratch1(), scratch2(), scratch3(), scratch4(), | 1411 __ bind(&success); |
1424 callback, name, &miss); | 1412 GenerateLoadCallback(reg, callback); |
1425 __ bind(&miss); | |
1426 GenerateLoadMiss(masm(), kind()); | |
1427 | 1413 |
1428 // Return the generated code. | 1414 // Return the generated code. |
1429 return GetCode(Code::CALLBACKS, name); | 1415 return GetCode(Code::CALLBACKS, name); |
1430 } | 1416 } |
1431 | 1417 |
1432 | 1418 |
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( | 1419 Handle<Code> BaseLoadStubCompiler::CompileLoadInterceptor( |
1453 Handle<JSObject> object, | 1420 Handle<JSObject> object, |
1454 Handle<JSObject> holder, | 1421 Handle<JSObject> holder, |
1455 Handle<String> name) { | 1422 Handle<String> name) { |
1456 Label miss; | 1423 Label success; |
1457 | 1424 |
1458 LookupResult lookup(isolate()); | 1425 LookupResult lookup(isolate()); |
1459 LookupPostInterceptor(holder, name, &lookup); | 1426 LookupPostInterceptor(holder, name, &lookup); |
1460 | 1427 |
1461 GenerateNameCheck(name, this->name(), &miss); | 1428 Register reg = GenerateHandlerFrontend( |
| 1429 object, receiver(), holder, name, |
| 1430 &success, Handle<AccessorInfo>::null(), true); |
| 1431 __ bind(&success); |
1462 // TODO(368): Compile in the whole chain: all the interceptors in | 1432 // TODO(368): Compile in the whole chain: all the interceptors in |
1463 // prototypes and ultimate answer. | 1433 // prototypes and ultimate answer. |
1464 GenerateLoadInterceptor(object, holder, &lookup, receiver(), this->name(), | 1434 GenerateLoadInterceptor(reg, object, holder, &lookup, name); |
1465 scratch1(), scratch2(), scratch3(), | |
1466 name, &miss); | |
1467 | |
1468 __ bind(&miss); | |
1469 GenerateLoadMiss(masm(), kind()); | |
1470 | 1435 |
1471 // Return the generated code. | 1436 // Return the generated code. |
1472 return GetCode(Code::INTERCEPTOR, name); | 1437 return GetCode(Code::INTERCEPTOR, name); |
1473 } | 1438 } |
1474 | 1439 |
1475 | 1440 |
1476 #undef __ | 1441 #undef __ |
1477 | 1442 |
1478 | 1443 |
1479 Handle<Code> LoadStubCompiler::GetCode(Code::StubType type, | 1444 Handle<Code> LoadStubCompiler::GetCode(Code::StubType type, |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1762 Handle<FunctionTemplateInfo>( | 1727 Handle<FunctionTemplateInfo>( |
1763 FunctionTemplateInfo::cast(signature->receiver())); | 1728 FunctionTemplateInfo::cast(signature->receiver())); |
1764 } | 1729 } |
1765 } | 1730 } |
1766 | 1731 |
1767 is_simple_api_call_ = true; | 1732 is_simple_api_call_ = true; |
1768 } | 1733 } |
1769 | 1734 |
1770 | 1735 |
1771 } } // namespace v8::internal | 1736 } } // namespace v8::internal |
OLD | NEW |