V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
ic-inl.h
1 // Copyright 2012 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 #ifndef V8_IC_IC_INL_H_
6 #define V8_IC_IC_INL_H_
7 
8 #include "src/ic/ic.h"
9 
10 #include "src/assembler-inl.h"
11 #include "src/debug/debug.h"
12 #include "src/frames-inl.h"
13 #include "src/handles-inl.h"
14 #include "src/prototype.h"
15 
16 namespace v8 {
17 namespace internal {
18 
19 
20 Address IC::address() const {
21  // Get the address of the call.
22  return Assembler::target_address_from_return_address(pc());
23 }
24 
25 
26 Address IC::constant_pool() const {
27  if (FLAG_enable_embedded_constant_pool) {
28  return raw_constant_pool();
29  } else {
30  return kNullAddress;
31  }
32 }
33 
34 
35 Address IC::raw_constant_pool() const {
36  if (FLAG_enable_embedded_constant_pool) {
37  return *constant_pool_address_;
38  } else {
39  return kNullAddress;
40  }
41 }
42 
43 void IC::update_receiver_map(Handle<Object> receiver) {
44  if (receiver->IsSmi()) {
45  receiver_map_ = isolate_->factory()->heap_number_map();
46  } else {
47  receiver_map_ = handle(HeapObject::cast(*receiver)->map(), isolate_);
48  }
49 }
50 
51 bool IC::IsHandler(MaybeObject object) {
52  HeapObject* heap_object;
53  return (object->IsSmi() && (object.ptr() != kNullAddress)) ||
54  (object->GetHeapObjectIfWeak(&heap_object) &&
55  (heap_object->IsMap() || heap_object->IsPropertyCell())) ||
56  (object->GetHeapObjectIfStrong(&heap_object) &&
57  (heap_object->IsDataHandler() || heap_object->IsCode()));
58 }
59 
60 bool IC::AddressIsDeoptimizedCode() const {
61  return AddressIsDeoptimizedCode(isolate(), address());
62 }
63 
64 // static
65 bool IC::AddressIsDeoptimizedCode(Isolate* isolate, Address address) {
66  Code host =
67  isolate->inner_pointer_to_code_cache()->GetCacheEntry(address)->code;
68  return (host->kind() == Code::OPTIMIZED_FUNCTION &&
69  host->marked_for_deoptimization());
70 }
71 
72 bool IC::vector_needs_update() {
73  return (!vector_set_ &&
74  (state() != MEGAMORPHIC ||
75  nexus()->GetFeedbackExtra().ToSmi().value() != ELEMENT));
76 }
77 
78 } // namespace internal
79 } // namespace v8
80 
81 #endif // V8_IC_IC_INL_H_
Definition: libplatform.h:13