trace-ic.js 1.38 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
// Copyright 2019 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: --trace-ic --logfile=test/mjsunit/tools/trace-ic-test.log
// Flags: --allow-natives-syntax

// The idea behind this test is to make sure we do not crash when using the
// --trace-ic flag.


(function testLoadIC() {
  function loadIC(obj) {
    return obj.field;
  }

  %EnsureFeedbackVectorForFunction(loadIC);

  var obj = {field: 'hello'};
  loadIC(obj);
  loadIC(obj);
  loadIC(obj);
})();

(function testStoreIC() {
  function storeIC(obj, value) {
    return obj.field = value;
  }

  %EnsureFeedbackVectorForFunction(storeIC);

  var obj = {field: 'hello'};
  storeIC(obj, 'world');
  storeIC(obj, 'world');
  storeIC(obj, 'world');
})();

(function testKeyedLoadIC() {
  function keyedLoadIC(obj, field) {
    return obj[field];
  }

  %EnsureFeedbackVectorForFunction(keyedLoadIC);

  var obj = {field: 'hello'};
  keyedLoadIC(obj, 'field');
  keyedLoadIC(obj, 'field');
  keyedLoadIC(obj, 'field');
})();

(function testKeyedStoreIC() {
  function keyedStoreIC(obj, field, value) {
    return obj[field] = value;
  }

  %EnsureFeedbackVectorForFunction(keyedStoreIC);

  var obj = {field: 'hello'};
  keyedStoreIC(obj, 'field', 'world');
  keyedStoreIC(obj, 'field', 'world');
  keyedStoreIC(obj, 'field', 'world');
})();