summaryrefslogtreecommitdiff
path: root/chromium/v8/src/builtins/internal.tq
blob: 9e7e4240ba21e8f5b48ed0ad3800026679124fdf (plain)
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
// Copyright 2020 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.

namespace internal {

namespace runtime {
extern runtime GetTemplateObject(implicit context: Context)(
    TemplateObjectDescription, SharedFunctionInfo, Smi): JSAny;
}

builtin GetTemplateObject(
    context: Context, shared: SharedFunctionInfo,
    description: TemplateObjectDescription, slot: uintptr,
    maybeFeedbackVector: FeedbackVector|Undefined): JSArray {
  // TODO(jgruber): Consider merging with the GetTemplateObject bytecode
  // handler; the current advantage of the split implementation is that the
  // bytecode can skip most work if feedback exists.

  try {
    const vector =
        Cast<FeedbackVector>(maybeFeedbackVector) otherwise CallRuntime;
    return Cast<JSArray>(ic::LoadFeedbackVectorSlot(vector, slot))
        otherwise CallRuntime;
  } label CallRuntime deferred {
    const result = UnsafeCast<JSArray>(runtime::GetTemplateObject(
        description, shared, Convert<Smi>(Signed(slot))));
    const vector =
        Cast<FeedbackVector>(maybeFeedbackVector) otherwise return result;
    ic::StoreFeedbackVectorSlot(vector, slot, result);
    return result;
  }
}

}  // namespace internal