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

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

Issue 1259853002: Cross-script variables handling fixed. It was possible to write to read-only global variable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/objects.cc ('k') | src/x64/code-stubs-x64.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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 // Go up context chain to the script context. 460 // Go up context chain to the script context.
461 Handle<Context> script_context(isolate->context()->script_context(), isolate); 461 Handle<Context> script_context(isolate->context()->script_context(), isolate);
462 DCHECK(script_context->IsScriptContext()); 462 DCHECK(script_context->IsScriptContext());
463 DCHECK(script_context->get(slot)->IsPropertyCell()); 463 DCHECK(script_context->get(slot)->IsPropertyCell());
464 464
465 // Lookup the named property on the global object. 465 // Lookup the named property on the global object.
466 Handle<GlobalObject> global_object(script_context->global_object(), isolate); 466 Handle<GlobalObject> global_object(script_context->global_object(), isolate);
467 LookupIterator it(global_object, name, LookupIterator::HIDDEN); 467 LookupIterator it(global_object, name, LookupIterator::HIDDEN);
468 // Switch to fast mode only if there is a data property and it's not on 468 // Switch to fast mode only if there is a data property and it's not on
469 // a hidden prototype. 469 // a hidden prototype.
470 if (LookupIterator::DATA == it.state() && 470 if (LookupIterator::DATA == it.state() && !it.IsReadOnly() &&
471 it.GetHolder<Object>()->IsJSGlobalObject()) { 471 it.GetHolder<Object>()->IsJSGlobalObject()) {
472 // Now update cell in the script context. 472 // Now update cell in the script context.
473 Handle<PropertyCell> cell = it.GetPropertyCell(); 473 Handle<PropertyCell> cell = it.GetPropertyCell();
474 script_context->set(slot, *cell); 474 script_context->set(slot, *cell);
475 } else { 475 } else {
476 // This is not a fast case, so keep this access in a slow mode. 476 // 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. 477 // Store empty_property_cell here to release the outdated property cell.
478 script_context->set(slot, isolate->heap()->empty_property_cell()); 478 script_context->set(slot, isolate->heap()->empty_property_cell());
479 } 479 }
480 480
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); 1453 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3);
1454 1454
1455 RETURN_FAILURE_ON_EXCEPTION( 1455 RETURN_FAILURE_ON_EXCEPTION(
1456 isolate, 1456 isolate,
1457 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), 1457 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(),
1458 setter, attrs)); 1458 setter, attrs));
1459 return isolate->heap()->undefined_value(); 1459 return isolate->heap()->undefined_value();
1460 } 1460 }
1461 } // namespace internal 1461 } // namespace internal
1462 } // namespace v8 1462 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698