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

Side by Side Diff: src/runtime/runtime-object.cc

Issue 1259963002: [stubs] Don't pass name to Load/StoreGlobalViaContext stubs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix rebase Created 5 years, 4 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 | « src/runtime/runtime.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/debug.h" 9 #include "src/debug.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 !object->map()->is_observed() && !object->IsJSProxy()); 413 !object->map()->is_observed() && !object->IsJSProxy());
414 414
415 Handle<Object> result; 415 Handle<Object> result;
416 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, JSObject::Seal(object)); 416 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, JSObject::Seal(object));
417 return *result; 417 return *result;
418 } 418 }
419 419
420 420
421 RUNTIME_FUNCTION(Runtime_LoadGlobalViaContext) { 421 RUNTIME_FUNCTION(Runtime_LoadGlobalViaContext) {
422 HandleScope scope(isolate); 422 HandleScope scope(isolate);
423 DCHECK_EQ(2, args.length()); 423 DCHECK_EQ(1, args.length());
424 CONVERT_SMI_ARG_CHECKED(slot, 0); 424 CONVERT_SMI_ARG_CHECKED(slot, 0);
425 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
426 425
427 // Go up context chain to the script context. 426 // Go up context chain to the script context.
428 Handle<Context> script_context(isolate->context()->script_context(), isolate); 427 Handle<Context> script_context(isolate->context()->script_context(), isolate);
429 DCHECK(script_context->IsScriptContext()); 428 DCHECK(script_context->IsScriptContext());
430 DCHECK(script_context->get(slot)->IsPropertyCell()); 429 DCHECK(script_context->get(slot)->IsPropertyCell());
431 430
432 // Lookup the named property on the global object. 431 // Lookup the named property on the global object.
432 Handle<ScopeInfo> scope_info(ScopeInfo::cast(script_context->extension()),
433 isolate);
434 Handle<Name> name(scope_info->ContextSlotName(slot), isolate);
433 Handle<GlobalObject> global_object(script_context->global_object(), isolate); 435 Handle<GlobalObject> global_object(script_context->global_object(), isolate);
434 LookupIterator it(global_object, name, LookupIterator::HIDDEN); 436 LookupIterator it(global_object, name, LookupIterator::HIDDEN);
435 437
436 // Switch to fast mode only if there is a data property and it's not on 438 // Switch to fast mode only if there is a data property and it's not on
437 // a hidden prototype. 439 // a hidden prototype.
438 if (it.state() == LookupIterator::DATA && 440 if (LookupIterator::DATA == it.state() &&
439 it.GetHolder<Object>()->IsJSGlobalObject()) { 441 it.GetHolder<Object>()->IsJSGlobalObject()) {
440 // Now update the cell in the script context. 442 // Now update the cell in the script context.
441 Handle<PropertyCell> cell = it.GetPropertyCell(); 443 Handle<PropertyCell> cell = it.GetPropertyCell();
442 script_context->set(slot, *cell); 444 script_context->set(slot, *cell);
443 } else { 445 } else {
444 // This is not a fast case, so keep this access in a slow mode. 446 // This is not a fast case, so keep this access in a slow mode.
445 // Store empty_property_cell here to release the outdated property cell. 447 // Store empty_property_cell here to release the outdated property cell.
446 script_context->set(slot, isolate->heap()->empty_property_cell()); 448 script_context->set(slot, isolate->heap()->empty_property_cell());
447 } 449 }
448 450
449 Handle<Object> result; 451 Handle<Object> result;
450 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); 452 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it));
451 return *result; 453 return *result;
452 } 454 }
453 455
454 456
455 namespace { 457 namespace {
456 458
457 Object* StoreGlobalViaContext(Isolate* isolate, int slot, Handle<Name> name, 459 Object* StoreGlobalViaContext(Isolate* isolate, int slot, Handle<Object> value,
458 Handle<Object> value,
459 LanguageMode language_mode) { 460 LanguageMode language_mode) {
460 // Go up context chain to the script context. 461 // Go up context chain to the script context.
461 Handle<Context> script_context(isolate->context()->script_context(), isolate); 462 Handle<Context> script_context(isolate->context()->script_context(), isolate);
462 DCHECK(script_context->IsScriptContext()); 463 DCHECK(script_context->IsScriptContext());
463 DCHECK(script_context->get(slot)->IsPropertyCell()); 464 DCHECK(script_context->get(slot)->IsPropertyCell());
464 465
465 // Lookup the named property on the global object. 466 // Lookup the named property on the global object.
467 Handle<ScopeInfo> scope_info(ScopeInfo::cast(script_context->extension()),
468 isolate);
469 Handle<Name> name(scope_info->ContextSlotName(slot), isolate);
466 Handle<GlobalObject> global_object(script_context->global_object(), isolate); 470 Handle<GlobalObject> global_object(script_context->global_object(), isolate);
467 LookupIterator it(global_object, name, LookupIterator::HIDDEN); 471 LookupIterator it(global_object, name, LookupIterator::HIDDEN);
468 // Switch to fast mode only if there is a data property and it's not on 472 // Switch to fast mode only if there is a data property and it's not on
469 // a hidden prototype. 473 // a hidden prototype.
470 if (LookupIterator::DATA == it.state() && 474 if (LookupIterator::DATA == it.state() &&
471 it.GetHolder<Object>()->IsJSGlobalObject()) { 475 it.GetHolder<Object>()->IsJSGlobalObject()) {
472 // Now update cell in the script context. 476 // Now update cell in the script context.
473 Handle<PropertyCell> cell = it.GetPropertyCell(); 477 Handle<PropertyCell> cell = it.GetPropertyCell();
474 script_context->set(slot, *cell); 478 script_context->set(slot, *cell);
475 } else { 479 } else {
476 // This is not a fast case, so keep this access in a slow mode. 480 // This is not a fast case, so keep this access in a slow mode.
477 // Store empty_property_cell here to release the outdated property cell. 481 // Store empty_property_cell here to release the outdated property cell.
478 script_context->set(slot, isolate->heap()->empty_property_cell()); 482 script_context->set(slot, isolate->heap()->empty_property_cell());
479 } 483 }
480 484
481 Handle<Object> result; 485 Handle<Object> result;
482 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 486 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
483 isolate, result, 487 isolate, result,
484 Object::SetProperty(&it, value, language_mode, 488 Object::SetProperty(&it, value, language_mode,
485 Object::CERTAINLY_NOT_STORE_FROM_KEYED)); 489 Object::CERTAINLY_NOT_STORE_FROM_KEYED));
486 return *result; 490 return *result;
487 } 491 }
488 492
489 } // namespace 493 } // namespace
490 494
491 495
492 RUNTIME_FUNCTION(Runtime_StoreGlobalViaContext_Sloppy) { 496 RUNTIME_FUNCTION(Runtime_StoreGlobalViaContext_Sloppy) {
493 HandleScope scope(isolate); 497 HandleScope scope(isolate);
494 DCHECK_EQ(3, args.length()); 498 DCHECK_EQ(2, args.length());
495 CONVERT_SMI_ARG_CHECKED(slot, 0); 499 CONVERT_SMI_ARG_CHECKED(slot, 0);
496 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); 500 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
497 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
498 501
499 return StoreGlobalViaContext(isolate, slot, name, value, SLOPPY); 502 return StoreGlobalViaContext(isolate, slot, value, SLOPPY);
500 } 503 }
501 504
502 505
503 RUNTIME_FUNCTION(Runtime_StoreGlobalViaContext_Strict) { 506 RUNTIME_FUNCTION(Runtime_StoreGlobalViaContext_Strict) {
504 HandleScope scope(isolate); 507 HandleScope scope(isolate);
505 DCHECK_EQ(3, args.length()); 508 DCHECK_EQ(2, args.length());
506 CONVERT_SMI_ARG_CHECKED(slot, 0); 509 CONVERT_SMI_ARG_CHECKED(slot, 0);
507 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); 510 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
508 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
509 511
510 return StoreGlobalViaContext(isolate, slot, name, value, STRICT); 512 return StoreGlobalViaContext(isolate, slot, value, STRICT);
511 } 513 }
512 514
513 515
514 RUNTIME_FUNCTION(Runtime_GetProperty) { 516 RUNTIME_FUNCTION(Runtime_GetProperty) {
515 HandleScope scope(isolate); 517 HandleScope scope(isolate);
516 DCHECK(args.length() == 2); 518 DCHECK(args.length() == 2);
517 519
518 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); 520 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
519 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 521 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
520 522
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); 1455 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3);
1454 1456
1455 RETURN_FAILURE_ON_EXCEPTION( 1457 RETURN_FAILURE_ON_EXCEPTION(
1456 isolate, 1458 isolate,
1457 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), 1459 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(),
1458 setter, attrs)); 1460 setter, attrs));
1459 return isolate->heap()->undefined_value(); 1461 return isolate->heap()->undefined_value();
1460 } 1462 }
1461 } // namespace internal 1463 } // namespace internal
1462 } // namespace v8 1464 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698