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 3 // found in the LICENSE file. 4 5 // Flags: --allow-natives-syntax 6 7 function push_wrapper(array, value) { 8 array.push(value); 9 } 10 function pop_wrapper(array) { 11 return array.pop(); 12 } 13 14 // Test the frzon arrays throw an exception if you try to push to them, both in 15 // optimized and non-optimized code. 16 var array = [2, 2]; 17 Object.freeze(array); 18 19 try { push_wrapper(array, 1); } catch (e) {} 20 assertEquals(2, array.length); 21 try { push_wrapper(array, 1); } catch (e) {} 22 assertEquals(2, array.length); 23 %OptimizeFunctionOnNextCall(push_wrapper); 24 try { push_wrapper(array, 1); } catch (e) {} 25 assertEquals(2, array.length); 26 try { push_wrapper(array, 1); } catch (e) {} 27 assertEquals(2, array.length); 28 29 try { pop_wrapper(array); } catch (e) {} 30 assertEquals(2, array.length); 31 try { pop_wrapper(array); } catch (e) {} 32 assertEquals(2, array.length); 33 %OptimizeFunctionOnNextCall(pop_wrapper); 34 try { pop_wrapper(array); } catch (e) {} 35 assertEquals(2, array.length); 36 try { pop_wrapper(array); } catch (e) {} 37 assertEquals(2, array.length); 38