The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / deps / v8 / src / ic-inl.h @ 40c0f755

History | View | Annotate | Download (3.5 KB)

1 40c0f755 Ryan
// Copyright 2006-2008 the V8 project authors. All rights reserved.
2
// Redistribution and use in source and binary forms, with or without
3
// modification, are permitted provided that the following conditions are
4
// met:
5
//
6
//     * Redistributions of source code must retain the above copyright
7
//       notice, this list of conditions and the following disclaimer.
8
//     * Redistributions in binary form must reproduce the above
9
//       copyright notice, this list of conditions and the following
10
//       disclaimer in the documentation and/or other materials provided
11
//       with the distribution.
12
//     * Neither the name of Google Inc. nor the names of its
13
//       contributors may be used to endorse or promote products derived
14
//       from this software without specific prior written permission.
15
//
16
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
#ifndef V8_IC_INL_H_
29
#define V8_IC_INL_H_
30
31
#include "ic.h"
32
#include "debug.h"
33
#include "macro-assembler.h"
34
35
namespace v8 { namespace internal {
36
37
38
Address IC::address() {
39
  // Get the address of the call.
40
  Address result = pc() - Assembler::kTargetAddrToReturnAddrDist;
41
42
  // First check if any break points are active if not just return the address
43
  // of the call.
44
  if (!Debug::has_break_points()) return result;
45
46
  // At least one break point is active perform additional test to ensure that
47
  // break point locations are updated correctly.
48
  if (Debug::IsDebugBreak(Assembler::target_address_at(result))) {
49
    // If the call site is a call to debug break then return the address in
50
    // the original code instead of the address in the running code. This will
51
    // cause the original code to be updated and keeps the breakpoint active in
52
    // the running code.
53
    return OriginalCodeAddress();
54
  } else {
55
    // No break point here just return the address of the call.
56
    return result;
57
  }
58
}
59
60
61
Code* IC::GetTargetAtAddress(Address address) {
62
  // Get the target address of the IC.
63
  Address target = Assembler::target_address_at(address);
64
  // Convert target address to the code object. Code::GetCodeFromTargetAddress
65
  // is safe for use during GC where the map might be marked.
66
  Code* result = Code::GetCodeFromTargetAddress(target);
67
  ASSERT(result->is_inline_cache_stub());
68
  return result;
69
}
70
71
72
void IC::SetTargetAtAddress(Address address, Code* target) {
73
  ASSERT(target->is_inline_cache_stub());
74
  Assembler::set_target_address_at(address, target->instruction_start());
75
}
76
77
78
Map* IC::GetCodeCacheMapForObject(Object* object) {
79
  if (object->IsJSObject()) return JSObject::cast(object)->map();
80
  // If the object is a value, we use the prototype map for the cache.
81
  ASSERT(object->IsString() || object->IsNumber() || object->IsBoolean());
82
  return JSObject::cast(object->GetPrototype())->map();
83
}
84
85
86
} }  // namespace v8::internal
87
88
#endif  // V8_IC_INL_H_