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

Side by Side Diff: src/objects.cc

Issue 2770003002: Set the current context to the function's context when entering to LAP. (Closed)
Patch Set: . Created 3 years, 8 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
« no previous file with comments | « no previous file | src/x64/code-stubs-x64.cc » ('j') | src/x64/code-stubs-x64.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 MaybeHandle<Object> Object::GetPropertyWithAccessor(LookupIterator* it) { 1357 MaybeHandle<Object> Object::GetPropertyWithAccessor(LookupIterator* it) {
1358 Isolate* isolate = it->isolate(); 1358 Isolate* isolate = it->isolate();
1359 Handle<Object> structure = it->GetAccessors(); 1359 Handle<Object> structure = it->GetAccessors();
1360 Handle<Object> receiver = it->GetReceiver(); 1360 Handle<Object> receiver = it->GetReceiver();
1361 1361
1362 // We should never get here to initialize a const with the hole value since a 1362 // We should never get here to initialize a const with the hole value since a
1363 // const declaration would conflict with the getter. 1363 // const declaration would conflict with the getter.
1364 DCHECK(!structure->IsForeign()); 1364 DCHECK(!structure->IsForeign());
1365 1365
1366 // API style callbacks. 1366 // API style callbacks.
1367 Handle<JSObject> holder = it->GetHolder<JSObject>();
1367 if (structure->IsAccessorInfo()) { 1368 if (structure->IsAccessorInfo()) {
1368 Handle<JSObject> holder = it->GetHolder<JSObject>();
1369 Handle<Name> name = it->GetName(); 1369 Handle<Name> name = it->GetName();
1370 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); 1370 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure);
1371 if (!info->IsCompatibleReceiver(*receiver)) { 1371 if (!info->IsCompatibleReceiver(*receiver)) {
1372 THROW_NEW_ERROR(isolate, 1372 THROW_NEW_ERROR(isolate,
1373 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, 1373 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver,
1374 name, receiver), 1374 name, receiver),
1375 Object); 1375 Object);
1376 } 1376 }
1377 1377
1378 v8::AccessorNameGetterCallback call_fun = 1378 v8::AccessorNameGetterCallback call_fun =
(...skipping 22 matching lines...) Expand all
1401 } 1401 }
1402 1402
1403 // AccessorPair with 'cached' private property. 1403 // AccessorPair with 'cached' private property.
1404 if (it->TryLookupCachedProperty()) { 1404 if (it->TryLookupCachedProperty()) {
1405 return Object::GetProperty(it); 1405 return Object::GetProperty(it);
1406 } 1406 }
1407 1407
1408 // Regular accessor. 1408 // Regular accessor.
1409 Handle<Object> getter(AccessorPair::cast(*structure)->getter(), isolate); 1409 Handle<Object> getter(AccessorPair::cast(*structure)->getter(), isolate);
1410 if (getter->IsFunctionTemplateInfo()) { 1410 if (getter->IsFunctionTemplateInfo()) {
1411 SaveContext save(isolate);
1412 isolate->set_context(*holder->GetCreationContext());
1411 return Builtins::InvokeApiFunction( 1413 return Builtins::InvokeApiFunction(
1412 isolate, false, Handle<FunctionTemplateInfo>::cast(getter), receiver, 0, 1414 isolate, false, Handle<FunctionTemplateInfo>::cast(getter), receiver, 0,
1413 nullptr, isolate->factory()->undefined_value()); 1415 nullptr, isolate->factory()->undefined_value());
1414 } else if (getter->IsCallable()) { 1416 } else if (getter->IsCallable()) {
1415 // TODO(rossberg): nicer would be to cast to some JSCallable here... 1417 // TODO(rossberg): nicer would be to cast to some JSCallable here...
1416 return Object::GetPropertyWithDefinedGetter( 1418 return Object::GetPropertyWithDefinedGetter(
1417 receiver, Handle<JSReceiver>::cast(getter)); 1419 receiver, Handle<JSReceiver>::cast(getter));
1418 } 1420 }
1419 // Getter is not a function. 1421 // Getter is not a function.
1420 return isolate->factory()->undefined_value(); 1422 return isolate->factory()->undefined_value();
(...skipping 28 matching lines...) Expand all
1449 ShouldThrow should_throw) { 1451 ShouldThrow should_throw) {
1450 Isolate* isolate = it->isolate(); 1452 Isolate* isolate = it->isolate();
1451 Handle<Object> structure = it->GetAccessors(); 1453 Handle<Object> structure = it->GetAccessors();
1452 Handle<Object> receiver = it->GetReceiver(); 1454 Handle<Object> receiver = it->GetReceiver();
1453 1455
1454 // We should never get here to initialize a const with the hole value since a 1456 // We should never get here to initialize a const with the hole value since a
1455 // const declaration would conflict with the setter. 1457 // const declaration would conflict with the setter.
1456 DCHECK(!structure->IsForeign()); 1458 DCHECK(!structure->IsForeign());
1457 1459
1458 // API style callbacks. 1460 // API style callbacks.
1461 Handle<JSObject> holder = it->GetHolder<JSObject>();
1459 if (structure->IsAccessorInfo()) { 1462 if (structure->IsAccessorInfo()) {
1460 Handle<JSObject> holder = it->GetHolder<JSObject>();
1461 Handle<Name> name = it->GetName(); 1463 Handle<Name> name = it->GetName();
1462 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); 1464 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure);
1463 if (!info->IsCompatibleReceiver(*receiver)) { 1465 if (!info->IsCompatibleReceiver(*receiver)) {
1464 isolate->Throw(*isolate->factory()->NewTypeError( 1466 isolate->Throw(*isolate->factory()->NewTypeError(
1465 MessageTemplate::kIncompatibleMethodReceiver, name, receiver)); 1467 MessageTemplate::kIncompatibleMethodReceiver, name, receiver));
1466 return Nothing<bool>(); 1468 return Nothing<bool>();
1467 } 1469 }
1468 1470
1469 // The actual type of call_fun is either v8::AccessorNameSetterCallback or 1471 // The actual type of call_fun is either v8::AccessorNameSetterCallback or
1470 // i::Accesors::AccessorNameBooleanSetterCallback, depending on whether the 1472 // i::Accesors::AccessorNameBooleanSetterCallback, depending on whether the
(...skipping 25 matching lines...) Expand all
1496 // (signalling an exception) or a boolean Oddball. 1498 // (signalling an exception) or a boolean Oddball.
1497 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>()); 1499 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>());
1498 if (result.is_null()) return Just(true); 1500 if (result.is_null()) return Just(true);
1499 DCHECK(result->BooleanValue() || should_throw == DONT_THROW); 1501 DCHECK(result->BooleanValue() || should_throw == DONT_THROW);
1500 return Just(result->BooleanValue()); 1502 return Just(result->BooleanValue());
1501 } 1503 }
1502 1504
1503 // Regular accessor. 1505 // Regular accessor.
1504 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); 1506 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate);
1505 if (setter->IsFunctionTemplateInfo()) { 1507 if (setter->IsFunctionTemplateInfo()) {
1508 SaveContext save(isolate);
1509 isolate->set_context(*holder->GetCreationContext());
1506 Handle<Object> argv[] = {value}; 1510 Handle<Object> argv[] = {value};
1507 RETURN_ON_EXCEPTION_VALUE( 1511 RETURN_ON_EXCEPTION_VALUE(
1508 isolate, Builtins::InvokeApiFunction( 1512 isolate, Builtins::InvokeApiFunction(
1509 isolate, false, Handle<FunctionTemplateInfo>::cast(setter), 1513 isolate, false, Handle<FunctionTemplateInfo>::cast(setter),
1510 receiver, arraysize(argv), argv, 1514 receiver, arraysize(argv), argv,
1511 isolate->factory()->undefined_value()), 1515 isolate->factory()->undefined_value()),
1512 Nothing<bool>()); 1516 Nothing<bool>());
1513 return Just(true); 1517 return Just(true);
1514 } else if (setter->IsCallable()) { 1518 } else if (setter->IsCallable()) {
1515 // TODO(rossberg): nicer would be to cast to some JSCallable here... 1519 // TODO(rossberg): nicer would be to cast to some JSCallable here...
(...skipping 18784 matching lines...) Expand 10 before | Expand all | Expand 10 after
20300 // depend on this. 20304 // depend on this.
20301 return DICTIONARY_ELEMENTS; 20305 return DICTIONARY_ELEMENTS;
20302 } 20306 }
20303 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20307 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20304 return kind; 20308 return kind;
20305 } 20309 }
20306 } 20310 }
20307 20311
20308 } // namespace internal 20312 } // namespace internal
20309 } // namespace v8 20313 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/x64/code-stubs-x64.cc » ('j') | src/x64/code-stubs-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698