File tree Expand file tree Collapse file tree 6 files changed +86
-9
lines changed
Expand file tree Collapse file tree 6 files changed +86
-9
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,7 @@ namespace internal {
254254 V (kUnexpectedReturnFromThrow , " Unexpectedly returned from a throw" ) \
255255 V (kUnsupportedSwitchStatement , " Unsupported switch statement" ) \
256256 V (kUnsupportedTaggedImmediate , " Unsupported tagged immediate" ) \
257+ V (kUnstableConstantTypeHeapObject , " Unstable constant-type heap object" ) \
257258 V (kVariableResolvedToWithContext , " Variable resolved to with context" ) \
258259 V (kWeShouldNotHaveAnEmptyLexicalContext , \
259260 " We should not have an empty lexical context" ) \
Original file line number Diff line number Diff line change @@ -196,13 +196,18 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
196196 Type* property_cell_value_type;
197197 MachineRepresentation representation = MachineRepresentation::kTagged ;
198198 if (property_cell_value->IsHeapObject ()) {
199+ // We cannot do anything if the {property_cell_value}s map is no
200+ // longer stable.
201+ Handle<Map> property_cell_value_map (
202+ Handle<HeapObject>::cast (property_cell_value)->map (), isolate ());
203+ if (!property_cell_value_map->is_stable ()) return NoChange ();
204+ dependencies ()->AssumeMapStable (property_cell_value_map);
205+
199206 // Check that the {value} is a HeapObject.
200207 value = effect = graph ()->NewNode (simplified ()->CheckHeapObject (),
201208 value, effect, control);
202209
203210 // Check {value} map agains the {property_cell} map.
204- Handle<Map> property_cell_value_map (
205- Handle<HeapObject>::cast (property_cell_value)->map (), isolate ());
206211 effect = graph ()->NewNode (
207212 simplified ()->CheckMaps (1 ), value,
208213 jsgraph ()->HeapConstant (property_cell_value_map), effect, control);
Original file line number Diff line number Diff line change @@ -6518,11 +6518,19 @@ void HOptimizedGraphBuilder::HandleGlobalVariableAssignment(
65186518 access = access.WithRepresentation (Representation::Smi ());
65196519 break ;
65206520 case PropertyCellConstantType::kStableMap : {
6521- // The map may no longer be stable, deopt if it's ever different from
6522- // what is currently there, which will allow for restablization.
6523- Handle<Map> map (HeapObject::cast (cell->value ())->map ());
6521+ // First check that the previous value of the {cell} still has the
6522+ // map that we are about to check the new {value} for. If not, then
6523+ // the stable map assumption was invalidated and we cannot continue
6524+ // with the optimized code.
6525+ Handle<HeapObject> cell_value (HeapObject::cast (cell->value ()));
6526+ Handle<Map> cell_value_map (cell_value->map ());
6527+ if (!cell_value_map->is_stable ()) {
6528+ return Bailout (kUnstableConstantTypeHeapObject );
6529+ }
6530+ top_info ()->dependencies ()->AssumeMapStable (cell_value_map);
6531+ // Now check that the new {value} is a HeapObject with the same map.
65246532 Add<HCheckHeapObject>(value);
6525- value = Add<HCheckMaps>(value, map );
6533+ value = Add<HCheckMaps>(value, cell_value_map );
65266534 access = access.WithRepresentation (Representation::HeapObject ());
65276535 break ;
65286536 }
Original file line number Diff line number Diff line change @@ -69,9 +69,11 @@ namespace internal {
6969// Assert that the given argument has a valid value for a LanguageMode
7070// and store it in a LanguageMode variable with the given name.
7171#define CONVERT_LANGUAGE_MODE_ARG_CHECKED (name, index ) \
72- CHECK (args[index]->IsSmi ()); \
73- CHECK (is_valid_language_mode(args.smi_at(index))); \
74- LanguageMode name = static_cast <LanguageMode>(args.smi_at(index));
72+ CHECK (args[index]->IsNumber ()); \
73+ int32_t __tmp_##name = 0 ; \
74+ CHECK (args[index]->ToInt32 (&__tmp_##name)); \
75+ CHECK (is_valid_language_mode(__tmp_##name)); \
76+ LanguageMode name = static_cast <LanguageMode>(__tmp_##name);
7577
7678// Assert that the given argument is a number within the Int32 range
7779// and convert it to int32_t. If the argument is not an Int32 we crash safely.
Original file line number Diff line number Diff line change 1+ // Copyright 2016 the V8 project authors. All rights reserved.
2+ // Use of this source code is governed by a BSD-style license that can be
3+ // found in the LICENSE file.
4+
5+ // Flags: --allow-natives-syntax
6+
7+ var n ;
8+
9+ function Ctor ( ) {
10+ n = new Set ( ) ;
11+ }
12+
13+ function Check ( ) {
14+ n . xyz = 0x826852f4 ;
15+ }
16+
17+ Ctor ( ) ;
18+ Ctor ( ) ;
19+ % OptimizeFunctionOnNextCall ( Ctor ) ;
20+ Ctor ( ) ;
21+
22+ Check ( ) ;
23+ Check ( ) ;
24+ % OptimizeFunctionOnNextCall ( Check ) ;
25+ Check ( ) ;
26+
27+ Ctor ( ) ;
28+ Check ( ) ;
29+
30+ parseInt ( 'AAAAAAAA' ) ;
Original file line number Diff line number Diff line change 1+ // Copyright 2016 the V8 project authors. All rights reserved.
2+ // Use of this source code is governed by a BSD-style license that can be
3+ // found in the LICENSE file.
4+
5+ // Flags: --allow-natives-syntax
6+
7+ var n ;
8+
9+ function Ctor ( ) {
10+ try { } catch ( e ) { }
11+ n = new Set ( ) ;
12+ }
13+
14+ function Check ( ) {
15+ n . xyz = 0x826852f4 ;
16+ }
17+
18+ Ctor ( ) ;
19+ Ctor ( ) ;
20+ % OptimizeFunctionOnNextCall ( Ctor ) ;
21+ Ctor ( ) ;
22+
23+ Check ( ) ;
24+ Check ( ) ;
25+ % OptimizeFunctionOnNextCall ( Check ) ;
26+ Check ( ) ;
27+
28+ Ctor ( ) ;
29+ Check ( ) ;
30+
31+ parseInt ( 'AAAAAAAA' ) ;
You can’t perform that action at this time.
0 commit comments