| 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>(); |  | 
| 1369   if (structure->IsAccessorInfo()) { | 1368   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()); |  | 
| 1414     return Builtins::InvokeApiFunction( | 1412     return Builtins::InvokeApiFunction( | 
| 1415         isolate, false, Handle<FunctionTemplateInfo>::cast(getter), receiver, 0, | 1413         isolate, false, Handle<FunctionTemplateInfo>::cast(getter), receiver, 0, | 
| 1416         nullptr, isolate->factory()->undefined_value()); | 1414         nullptr, isolate->factory()->undefined_value()); | 
| 1417   } else if (getter->IsCallable()) { | 1415   } else if (getter->IsCallable()) { | 
| 1418     // TODO(rossberg): nicer would be to cast to some JSCallable here... | 1416     // TODO(rossberg): nicer would be to cast to some JSCallable here... | 
| 1419     return Object::GetPropertyWithDefinedGetter( | 1417     return Object::GetPropertyWithDefinedGetter( | 
| 1420         receiver, Handle<JSReceiver>::cast(getter)); | 1418         receiver, Handle<JSReceiver>::cast(getter)); | 
| 1421   } | 1419   } | 
| 1422   // Getter is not a function. | 1420   // Getter is not a function. | 
| 1423   return isolate->factory()->undefined_value(); | 1421   return isolate->factory()->undefined_value(); | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1457   // global proxy. | 1455   // global proxy. | 
| 1458   if (receiver->IsJSGlobalObject()) { | 1456   if (receiver->IsJSGlobalObject()) { | 
| 1459     receiver = handle(JSGlobalObject::cast(*receiver)->global_proxy(), isolate); | 1457     receiver = handle(JSGlobalObject::cast(*receiver)->global_proxy(), isolate); | 
| 1460   } | 1458   } | 
| 1461 | 1459 | 
| 1462   // We should never get here to initialize a const with the hole value since a | 1460   // We should never get here to initialize a const with the hole value since a | 
| 1463   // const declaration would conflict with the setter. | 1461   // const declaration would conflict with the setter. | 
| 1464   DCHECK(!structure->IsForeign()); | 1462   DCHECK(!structure->IsForeign()); | 
| 1465 | 1463 | 
| 1466   // API style callbacks. | 1464   // API style callbacks. | 
| 1467   Handle<JSObject> holder = it->GetHolder<JSObject>(); |  | 
| 1468   if (structure->IsAccessorInfo()) { | 1465   if (structure->IsAccessorInfo()) { | 
|  | 1466     Handle<JSObject> holder = it->GetHolder<JSObject>(); | 
| 1469     Handle<Name> name = it->GetName(); | 1467     Handle<Name> name = it->GetName(); | 
| 1470     Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); | 1468     Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); | 
| 1471     if (!info->IsCompatibleReceiver(*receiver)) { | 1469     if (!info->IsCompatibleReceiver(*receiver)) { | 
| 1472       isolate->Throw(*isolate->factory()->NewTypeError( | 1470       isolate->Throw(*isolate->factory()->NewTypeError( | 
| 1473           MessageTemplate::kIncompatibleMethodReceiver, name, receiver)); | 1471           MessageTemplate::kIncompatibleMethodReceiver, name, receiver)); | 
| 1474       return Nothing<bool>(); | 1472       return Nothing<bool>(); | 
| 1475     } | 1473     } | 
| 1476 | 1474 | 
| 1477     // The actual type of call_fun is either v8::AccessorNameSetterCallback or | 1475     // The actual type of call_fun is either v8::AccessorNameSetterCallback or | 
| 1478     // i::Accesors::AccessorNameBooleanSetterCallback, depending on whether the | 1476     // i::Accesors::AccessorNameBooleanSetterCallback, depending on whether the | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 1504     // (signalling an exception) or a boolean Oddball. | 1502     // (signalling an exception) or a boolean Oddball. | 
| 1505     RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>()); | 1503     RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>()); | 
| 1506     if (result.is_null()) return Just(true); | 1504     if (result.is_null()) return Just(true); | 
| 1507     DCHECK(result->BooleanValue() || should_throw == DONT_THROW); | 1505     DCHECK(result->BooleanValue() || should_throw == DONT_THROW); | 
| 1508     return Just(result->BooleanValue()); | 1506     return Just(result->BooleanValue()); | 
| 1509   } | 1507   } | 
| 1510 | 1508 | 
| 1511   // Regular accessor. | 1509   // Regular accessor. | 
| 1512   Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); | 1510   Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); | 
| 1513   if (setter->IsFunctionTemplateInfo()) { | 1511   if (setter->IsFunctionTemplateInfo()) { | 
| 1514     SaveContext save(isolate); |  | 
| 1515     isolate->set_context(*holder->GetCreationContext()); |  | 
| 1516     Handle<Object> argv[] = {value}; | 1512     Handle<Object> argv[] = {value}; | 
| 1517     RETURN_ON_EXCEPTION_VALUE( | 1513     RETURN_ON_EXCEPTION_VALUE( | 
| 1518         isolate, Builtins::InvokeApiFunction( | 1514         isolate, Builtins::InvokeApiFunction( | 
| 1519                      isolate, false, Handle<FunctionTemplateInfo>::cast(setter), | 1515                      isolate, false, Handle<FunctionTemplateInfo>::cast(setter), | 
| 1520                      receiver, arraysize(argv), argv, | 1516                      receiver, arraysize(argv), argv, | 
| 1521                      isolate->factory()->undefined_value()), | 1517                      isolate->factory()->undefined_value()), | 
| 1522         Nothing<bool>()); | 1518         Nothing<bool>()); | 
| 1523     return Just(true); | 1519     return Just(true); | 
| 1524   } else if (setter->IsCallable()) { | 1520   } else if (setter->IsCallable()) { | 
| 1525     // TODO(rossberg): nicer would be to cast to some JSCallable here... | 1521     // TODO(rossberg): nicer would be to cast to some JSCallable here... | 
| (...skipping 18667 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 20193       // not | 20189       // not | 
| 20194       // depend on this. | 20190       // depend on this. | 
| 20195       return DICTIONARY_ELEMENTS; | 20191       return DICTIONARY_ELEMENTS; | 
| 20196     } | 20192     } | 
| 20197     DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20193     DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 
| 20198     return kind; | 20194     return kind; | 
| 20199   } | 20195   } | 
| 20200 } | 20196 } | 
| 20201 }  // namespace internal | 20197 }  // namespace internal | 
| 20202 }  // namespace v8 | 20198 }  // namespace v8 | 
| OLD | NEW | 
|---|