2014-10-01 13:17:34 +00:00
|
|
|
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
// Flags: --allow-natives-syntax
|
|
|
|
|
|
|
|
function foo(x) {
|
|
|
|
var k = "value";
|
|
|
|
return x[k] = 1;
|
2019-06-12 14:00:50 +00:00
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
2014-10-01 13:17:34 +00:00
|
|
|
var obj = {};
|
2019-06-12 14:00:50 +00:00
|
|
|
Object.defineProperty(obj, 'value', {
|
|
|
|
set: function(x) {
|
|
|
|
throw 'nope';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
try {
|
|
|
|
foo(obj);
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
foo(obj);
|
|
|
|
} catch (e) {
|
|
|
|
}
|
2014-10-01 13:17:34 +00:00
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
2019-06-12 14:00:50 +00:00
|
|
|
try {
|
|
|
|
foo(obj);
|
|
|
|
} catch (e) {
|
|
|
|
}
|
2014-10-01 13:17:34 +00:00
|
|
|
|
|
|
|
function bar(x) {
|
|
|
|
var k = "value";
|
|
|
|
return (x[k] = 1) ? "ok" : "nope";
|
2019-06-12 14:00:50 +00:00
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(bar);
|
2014-10-01 13:17:34 +00:00
|
|
|
var obj2 = {};
|
2019-06-12 14:00:50 +00:00
|
|
|
Object.defineProperty(obj2, 'value', {
|
|
|
|
set: function(x) {
|
|
|
|
throw 'nope';
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2014-10-01 13:17:34 +00:00
|
|
|
|
2019-06-12 14:00:50 +00:00
|
|
|
try {
|
|
|
|
bar(obj2);
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
bar(obj2);
|
|
|
|
} catch (e) {
|
|
|
|
}
|
2014-10-01 13:17:34 +00:00
|
|
|
%OptimizeFunctionOnNextCall(bar);
|
2019-06-12 14:00:50 +00:00
|
|
|
try {
|
|
|
|
bar(obj2);
|
|
|
|
} catch (e) {
|
|
|
|
}
|