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

Side by Side Diff: src/x87/code-stubs-x87.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/x64/code-stubs-x64.cc ('k') | test/mjsunit/regress/cross-script-vars.js » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #if V8_TARGET_ARCH_X87 7 #if V8_TARGET_ARCH_X87
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 4815 matching lines...) Expand 10 before | Expand all | Expand 10 after
4826 4826
4827 // Go up context chain to the script context. 4827 // Go up context chain to the script context.
4828 for (int i = 0; i < depth(); ++i) { 4828 for (int i = 0; i < depth(); ++i) {
4829 __ mov(cell_reg, ContextOperand(context_reg, Context::PREVIOUS_INDEX)); 4829 __ mov(cell_reg, ContextOperand(context_reg, Context::PREVIOUS_INDEX));
4830 context_reg = cell_reg; 4830 context_reg = cell_reg;
4831 } 4831 }
4832 4832
4833 // Load the PropertyCell at the specified slot. 4833 // Load the PropertyCell at the specified slot.
4834 __ mov(cell_reg, ContextOperand(context_reg, slot_reg)); 4834 __ mov(cell_reg, ContextOperand(context_reg, slot_reg));
4835 4835
4836 // Check that cell value is not the_hole.
4837 {
4838 // TODO(bmeurer): use ecx (name_reg) when name parameter is removed.
4839 Register cell_value_reg = cell_details_reg;
4840 __ mov(cell_value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset));
4841 __ CompareRoot(cell_value_reg, Heap::kTheHoleValueRootIndex);
4842 __ j(equal, &slow_case, FLAG_debug_code ? Label::kFar : Label::kNear);
4843 }
4844
4836 // Load PropertyDetails for the cell (actually only the cell_type and kind). 4845 // Load PropertyDetails for the cell (actually only the cell_type and kind).
4837 __ mov(cell_details_reg, 4846 __ mov(cell_details_reg,
4838 FieldOperand(cell_reg, PropertyCell::kDetailsOffset)); 4847 FieldOperand(cell_reg, PropertyCell::kDetailsOffset));
4839 __ SmiUntag(cell_details_reg); 4848 __ SmiUntag(cell_details_reg);
4840 __ and_(cell_details_reg, 4849 __ and_(cell_details_reg,
4841 Immediate(PropertyDetails::PropertyCellTypeField::kMask | 4850 Immediate(PropertyDetails::PropertyCellTypeField::kMask |
4842 PropertyDetails::KindField::kMask)); 4851 PropertyDetails::KindField::kMask));
4843 4852
4844 4853
4845 // Check if PropertyCell holds mutable data. 4854 // Check if PropertyCell holds mutable data.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4893 // Check if PropertyCell contains data with constant type. 4902 // Check if PropertyCell contains data with constant type.
4894 __ cmp(cell_details_reg, 4903 __ cmp(cell_details_reg,
4895 Immediate(PropertyDetails::PropertyCellTypeField::encode( 4904 Immediate(PropertyDetails::PropertyCellTypeField::encode(
4896 PropertyCellType::kConstantType) | 4905 PropertyCellType::kConstantType) |
4897 PropertyDetails::KindField::encode(kData))); 4906 PropertyDetails::KindField::encode(kData)));
4898 __ j(not_equal, &slow_case, Label::kNear); 4907 __ j(not_equal, &slow_case, Label::kNear);
4899 4908
4900 // Now either both old and new values must be SMIs or both must be heap 4909 // Now either both old and new values must be SMIs or both must be heap
4901 // objects with same map. 4910 // objects with same map.
4902 Label value_is_heap_object; 4911 Label value_is_heap_object;
4912 // TODO(bmeurer): use ecx (name_reg) when name parameter is removed.
4903 Register cell_value_reg = cell_details_reg; 4913 Register cell_value_reg = cell_details_reg;
4904 __ mov(cell_value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset)); 4914 __ mov(cell_value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset));
4905 __ JumpIfNotSmi(value_reg, &value_is_heap_object, Label::kNear); 4915 __ JumpIfNotSmi(value_reg, &value_is_heap_object, Label::kNear);
4906 __ JumpIfNotSmi(cell_value_reg, &slow_case, Label::kNear); 4916 __ JumpIfNotSmi(cell_value_reg, &slow_case, Label::kNear);
4907 // Old and new values are SMIs, no need for a write barrier here. 4917 // Old and new values are SMIs, no need for a write barrier here.
4908 __ bind(&fast_smi_case); 4918 __ bind(&fast_smi_case);
4909 __ mov(FieldOperand(cell_reg, PropertyCell::kValueOffset), value_reg); 4919 __ mov(FieldOperand(cell_reg, PropertyCell::kValueOffset), value_reg);
4910 __ Ret(); 4920 __ Ret();
4911 __ bind(&value_is_heap_object); 4921 __ bind(&value_is_heap_object);
4912 __ JumpIfSmi(cell_value_reg, &slow_case, Label::kNear); 4922 __ JumpIfSmi(cell_value_reg, &slow_case, Label::kNear);
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
5314 Operand(ebp, 7 * kPointerSize), NULL); 5324 Operand(ebp, 7 * kPointerSize), NULL);
5315 } 5325 }
5316 5326
5317 5327
5318 #undef __ 5328 #undef __
5319 5329
5320 } // namespace internal 5330 } // namespace internal
5321 } // namespace v8 5331 } // namespace v8
5322 5332
5323 #endif // V8_TARGET_ARCH_X87 5333 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/x64/code-stubs-x64.cc ('k') | test/mjsunit/regress/cross-script-vars.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698