2017-09-04 16:56:30 +00:00
|
|
|
// Copyright 2017 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
|
|
|
|
|
2018-06-21 14:24:46 +00:00
|
|
|
// Flags: --allow-natives-syntax
|
2017-09-04 16:56:30 +00:00
|
|
|
|
|
|
|
Debug = debug.Debug
|
|
|
|
|
|
|
|
eval("var something1 = 25; "
|
|
|
|
+ " function ChooseAnimal() { return 'Cat'; } "
|
|
|
|
+ " ChooseAnimal.Helper = function() { return 'Help!'; }");
|
|
|
|
|
|
|
|
function foo() { return ChooseAnimal() }
|
|
|
|
|
2019-04-29 13:14:40 +00:00
|
|
|
%PrepareFunctionForOptimization(foo);
|
2017-09-04 16:56:30 +00:00
|
|
|
assertEquals("Cat", foo());
|
2019-04-29 13:14:40 +00:00
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
2017-09-04 16:56:30 +00:00
|
|
|
|
|
|
|
foo();
|
|
|
|
|
2018-06-21 14:24:46 +00:00
|
|
|
var new_source =
|
|
|
|
Debug.scriptSource(ChooseAnimal).replace('Cat', "Cap' + 'y' + 'bara");
|
|
|
|
print('new source: ' + new_source);
|
2017-09-04 16:56:30 +00:00
|
|
|
|
2018-06-21 14:24:46 +00:00
|
|
|
%LiveEditPatchScript(ChooseAnimal, new_source);
|
2017-09-04 16:56:30 +00:00
|
|
|
|
|
|
|
assertEquals("Capybara", foo());
|