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

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

Issue 1224793002: Loads and stores to global vars are now made via property cell shortcuts installed into parent scri… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressing comments Created 5 years, 5 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/scopes.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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // %ObjectSeal is a fast path and these cases are handled elsewhere. 441 // %ObjectSeal is a fast path and these cases are handled elsewhere.
442 RUNTIME_ASSERT(!object->HasSloppyArgumentsElements() && 442 RUNTIME_ASSERT(!object->HasSloppyArgumentsElements() &&
443 !object->map()->is_observed() && !object->IsJSProxy()); 443 !object->map()->is_observed() && !object->IsJSProxy());
444 444
445 Handle<Object> result; 445 Handle<Object> result;
446 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, JSObject::Seal(object)); 446 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, JSObject::Seal(object));
447 return *result; 447 return *result;
448 } 448 }
449 449
450 450
451 RUNTIME_FUNCTION(Runtime_LoadGlobalViaContext) {
452 HandleScope scope(isolate);
453 DCHECK(args.length() == 3);
454 CONVERT_ARG_HANDLE_CHECKED(Context, script_context, 0);
455 CONVERT_SMI_ARG_CHECKED(index, 1);
456 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2);
457 DCHECK(script_context->IsScriptContext());
458 DCHECK(script_context->get(index)->IsPropertyCell());
459
460 Handle<GlobalObject> global(script_context->global_object());
461
462 LookupIterator it(global, name, LookupIterator::OWN);
463 if (LookupIterator::DATA == it.state()) {
464 // Now update cell in the script context.
465 Handle<PropertyCell> cell = it.GetPropertyCell();
466 script_context->set(index, *cell);
467 } else {
468 // This is not a fast case, so keep this access in a slow mode.
469 // Store empty_property_cell here to release the outdated property cell.
470 script_context->set(index, isolate->heap()->empty_property_cell());
471 }
472
473 Handle<Object> result;
474 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it));
475
476 return *result;
477 }
478
479
480 RUNTIME_FUNCTION(Runtime_StoreGlobalViaContext) {
481 HandleScope scope(isolate);
482 DCHECK(args.length() == 5);
483 CONVERT_ARG_HANDLE_CHECKED(Context, script_context, 0);
484 CONVERT_SMI_ARG_CHECKED(index, 1);
485 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2);
486 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3);
487 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode_arg, 4);
488 DCHECK(script_context->IsScriptContext());
489 DCHECK(script_context->get(index)->IsPropertyCell());
490 LanguageMode language_mode = language_mode_arg;
491
492 Handle<GlobalObject> global(script_context->global_object());
493
494 LookupIterator it(global, name, LookupIterator::OWN);
495 if (LookupIterator::DATA == it.state()) {
496 // Now update cell in the script context.
497 Handle<PropertyCell> cell = it.GetPropertyCell();
498 script_context->set(index, *cell);
499 } else {
500 // This is not a fast case, so keep this access in a slow mode.
501 // Store empty_property_cell here to release the outdated property cell.
502 script_context->set(index, isolate->heap()->empty_property_cell());
503 }
504
505 Handle<Object> result;
506 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
507 isolate, result,
508 Object::SetProperty(&it, value, language_mode,
509 Object::CERTAINLY_NOT_STORE_FROM_KEYED));
510
511 return *result;
512 }
513
514
451 RUNTIME_FUNCTION(Runtime_GetProperty) { 515 RUNTIME_FUNCTION(Runtime_GetProperty) {
452 HandleScope scope(isolate); 516 HandleScope scope(isolate);
453 DCHECK(args.length() == 2); 517 DCHECK(args.length() == 2);
454 518
455 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); 519 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
456 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 520 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
457 521
458 Handle<Object> result; 522 Handle<Object> result;
459 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 523 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
460 isolate, result, 524 isolate, result,
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); 1494 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3);
1431 1495
1432 RETURN_FAILURE_ON_EXCEPTION( 1496 RETURN_FAILURE_ON_EXCEPTION(
1433 isolate, 1497 isolate,
1434 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), 1498 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(),
1435 setter, attrs)); 1499 setter, attrs));
1436 return isolate->heap()->undefined_value(); 1500 return isolate->heap()->undefined_value();
1437 } 1501 }
1438 } // namespace internal 1502 } // namespace internal
1439 } // namespace v8 1503 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698