| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/objects.h" | 5 #include "src/objects.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 // global proxy. | 1358 // global proxy. |
| 1359 if (receiver->IsJSGlobalObject()) { | 1359 if (receiver->IsJSGlobalObject()) { |
| 1360 receiver = handle(JSGlobalObject::cast(*receiver)->global_proxy(), isolate); | 1360 receiver = handle(JSGlobalObject::cast(*receiver)->global_proxy(), isolate); |
| 1361 } | 1361 } |
| 1362 | 1362 |
| 1363 // We should never get here to initialize a const with the hole value since a | 1363 // We should never get here to initialize a const with the hole value since a |
| 1364 // const declaration would conflict with the getter. | 1364 // const declaration would conflict with the getter. |
| 1365 DCHECK(!structure->IsForeign()); | 1365 DCHECK(!structure->IsForeign()); |
| 1366 | 1366 |
| 1367 // API style callbacks. | 1367 // API style callbacks. |
| 1368 Handle<JSObject> holder = it->GetHolder<JSObject>(); |
| 1368 if (structure->IsAccessorInfo()) { | 1369 if (structure->IsAccessorInfo()) { |
| 1369 Handle<JSObject> holder = it->GetHolder<JSObject>(); | |
| 1370 Handle<Name> name = it->GetName(); | 1370 Handle<Name> name = it->GetName(); |
| 1371 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); | 1371 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); |
| 1372 if (!info->IsCompatibleReceiver(*receiver)) { | 1372 if (!info->IsCompatibleReceiver(*receiver)) { |
| 1373 THROW_NEW_ERROR(isolate, | 1373 THROW_NEW_ERROR(isolate, |
| 1374 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, | 1374 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, |
| 1375 name, receiver), | 1375 name, receiver), |
| 1376 Object); | 1376 Object); |
| 1377 } | 1377 } |
| 1378 | 1378 |
| 1379 v8::AccessorNameGetterCallback call_fun = | 1379 v8::AccessorNameGetterCallback call_fun = |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1402 } | 1402 } |
| 1403 | 1403 |
| 1404 // AccessorPair with 'cached' private property. | 1404 // AccessorPair with 'cached' private property. |
| 1405 if (it->TryLookupCachedProperty()) { | 1405 if (it->TryLookupCachedProperty()) { |
| 1406 return Object::GetProperty(it); | 1406 return Object::GetProperty(it); |
| 1407 } | 1407 } |
| 1408 | 1408 |
| 1409 // Regular accessor. | 1409 // Regular accessor. |
| 1410 Handle<Object> getter(AccessorPair::cast(*structure)->getter(), isolate); | 1410 Handle<Object> getter(AccessorPair::cast(*structure)->getter(), isolate); |
| 1411 if (getter->IsFunctionTemplateInfo()) { | 1411 if (getter->IsFunctionTemplateInfo()) { |
| 1412 SaveContext save(isolate); |
| 1413 isolate->set_context(*holder->GetCreationContext()); |
| 1412 return Builtins::InvokeApiFunction( | 1414 return Builtins::InvokeApiFunction( |
| 1413 isolate, false, Handle<FunctionTemplateInfo>::cast(getter), receiver, 0, | 1415 isolate, false, Handle<FunctionTemplateInfo>::cast(getter), receiver, 0, |
| 1414 nullptr, isolate->factory()->undefined_value()); | 1416 nullptr, isolate->factory()->undefined_value()); |
| 1415 } else if (getter->IsCallable()) { | 1417 } else if (getter->IsCallable()) { |
| 1416 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 1418 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
| 1417 return Object::GetPropertyWithDefinedGetter( | 1419 return Object::GetPropertyWithDefinedGetter( |
| 1418 receiver, Handle<JSReceiver>::cast(getter)); | 1420 receiver, Handle<JSReceiver>::cast(getter)); |
| 1419 } | 1421 } |
| 1420 // Getter is not a function. | 1422 // Getter is not a function. |
| 1421 return isolate->factory()->undefined_value(); | 1423 return isolate->factory()->undefined_value(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 // global proxy. | 1457 // global proxy. |
| 1456 if (receiver->IsJSGlobalObject()) { | 1458 if (receiver->IsJSGlobalObject()) { |
| 1457 receiver = handle(JSGlobalObject::cast(*receiver)->global_proxy(), isolate); | 1459 receiver = handle(JSGlobalObject::cast(*receiver)->global_proxy(), isolate); |
| 1458 } | 1460 } |
| 1459 | 1461 |
| 1460 // We should never get here to initialize a const with the hole value since a | 1462 // We should never get here to initialize a const with the hole value since a |
| 1461 // const declaration would conflict with the setter. | 1463 // const declaration would conflict with the setter. |
| 1462 DCHECK(!structure->IsForeign()); | 1464 DCHECK(!structure->IsForeign()); |
| 1463 | 1465 |
| 1464 // API style callbacks. | 1466 // API style callbacks. |
| 1467 Handle<JSObject> holder = it->GetHolder<JSObject>(); |
| 1465 if (structure->IsAccessorInfo()) { | 1468 if (structure->IsAccessorInfo()) { |
| 1466 Handle<JSObject> holder = it->GetHolder<JSObject>(); | |
| 1467 Handle<Name> name = it->GetName(); | 1469 Handle<Name> name = it->GetName(); |
| 1468 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); | 1470 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); |
| 1469 if (!info->IsCompatibleReceiver(*receiver)) { | 1471 if (!info->IsCompatibleReceiver(*receiver)) { |
| 1470 isolate->Throw(*isolate->factory()->NewTypeError( | 1472 isolate->Throw(*isolate->factory()->NewTypeError( |
| 1471 MessageTemplate::kIncompatibleMethodReceiver, name, receiver)); | 1473 MessageTemplate::kIncompatibleMethodReceiver, name, receiver)); |
| 1472 return Nothing<bool>(); | 1474 return Nothing<bool>(); |
| 1473 } | 1475 } |
| 1474 | 1476 |
| 1475 // The actual type of call_fun is either v8::AccessorNameSetterCallback or | 1477 // The actual type of call_fun is either v8::AccessorNameSetterCallback or |
| 1476 // i::Accesors::AccessorNameBooleanSetterCallback, depending on whether the | 1478 // i::Accesors::AccessorNameBooleanSetterCallback, depending on whether the |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1502 // (signalling an exception) or a boolean Oddball. | 1504 // (signalling an exception) or a boolean Oddball. |
| 1503 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>()); | 1505 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>()); |
| 1504 if (result.is_null()) return Just(true); | 1506 if (result.is_null()) return Just(true); |
| 1505 DCHECK(result->BooleanValue() || should_throw == DONT_THROW); | 1507 DCHECK(result->BooleanValue() || should_throw == DONT_THROW); |
| 1506 return Just(result->BooleanValue()); | 1508 return Just(result->BooleanValue()); |
| 1507 } | 1509 } |
| 1508 | 1510 |
| 1509 // Regular accessor. | 1511 // Regular accessor. |
| 1510 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); | 1512 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); |
| 1511 if (setter->IsFunctionTemplateInfo()) { | 1513 if (setter->IsFunctionTemplateInfo()) { |
| 1514 SaveContext save(isolate); |
| 1515 isolate->set_context(*holder->GetCreationContext()); |
| 1512 Handle<Object> argv[] = {value}; | 1516 Handle<Object> argv[] = {value}; |
| 1513 RETURN_ON_EXCEPTION_VALUE( | 1517 RETURN_ON_EXCEPTION_VALUE( |
| 1514 isolate, Builtins::InvokeApiFunction( | 1518 isolate, Builtins::InvokeApiFunction( |
| 1515 isolate, false, Handle<FunctionTemplateInfo>::cast(setter), | 1519 isolate, false, Handle<FunctionTemplateInfo>::cast(setter), |
| 1516 receiver, arraysize(argv), argv, | 1520 receiver, arraysize(argv), argv, |
| 1517 isolate->factory()->undefined_value()), | 1521 isolate->factory()->undefined_value()), |
| 1518 Nothing<bool>()); | 1522 Nothing<bool>()); |
| 1519 return Just(true); | 1523 return Just(true); |
| 1520 } else if (setter->IsCallable()) { | 1524 } else if (setter->IsCallable()) { |
| 1521 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 1525 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
| (...skipping 18793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20315 // not | 20319 // not |
| 20316 // depend on this. | 20320 // depend on this. |
| 20317 return DICTIONARY_ELEMENTS; | 20321 return DICTIONARY_ELEMENTS; |
| 20318 } | 20322 } |
| 20319 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20323 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
| 20320 return kind; | 20324 return kind; |
| 20321 } | 20325 } |
| 20322 } | 20326 } |
| 20323 } // namespace internal | 20327 } // namespace internal |
| 20324 } // namespace v8 | 20328 } // namespace v8 |
| OLD | NEW |