blob: 132f08315fed35f18caafb21b2248a56803af9fd [file] [log] [blame]
rossberg@chromium.org994edf62012-02-06 10:12:55 +00001// Copyright 2012 the V8 project authors. All rights reserved.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +00002// 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#include "v8.h"
29
kasperl@chromium.org71affb52009-05-26 05:44:31 +000030namespace v8 {
31namespace internal {
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000032
33
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +000034void LookupResult::Iterate(ObjectVisitor* visitor) {
35 LookupResult* current = this; // Could be NULL.
36 while (current != NULL) {
37 visitor->VisitPointer(BitCast<Object**>(&current->holder_));
38 current = current->next_;
39 }
40}
41
42
whesse@chromium.org023421e2010-12-21 12:19:12 +000043#ifdef OBJECT_PRINT
44void LookupResult::Print(FILE* out) {
ager@chromium.org5c838252010-02-19 08:53:10 +000045 if (!IsFound()) {
whesse@chromium.org023421e2010-12-21 12:19:12 +000046 PrintF(out, "Not Found\n");
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000047 return;
48 }
49
whesse@chromium.org023421e2010-12-21 12:19:12 +000050 PrintF(out, "LookupResult:\n");
51 PrintF(out, " -cacheable = %s\n", IsCacheable() ? "true" : "false");
52 PrintF(out, " -attributes = %x\n", GetAttributes());
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000053 switch (type()) {
54 case NORMAL:
whesse@chromium.org023421e2010-12-21 12:19:12 +000055 PrintF(out, " -type = normal\n");
56 PrintF(out, " -entry = %d", GetDictionaryEntry());
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000057 break;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000058 case CONSTANT_FUNCTION:
whesse@chromium.org023421e2010-12-21 12:19:12 +000059 PrintF(out, " -type = constant function\n");
60 PrintF(out, " -function:\n");
61 GetConstantFunction()->Print(out);
62 PrintF(out, "\n");
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000063 break;
64 case FIELD:
whesse@chromium.org023421e2010-12-21 12:19:12 +000065 PrintF(out, " -type = field\n");
66 PrintF(out, " -index = %d", GetFieldIndex());
67 PrintF(out, "\n");
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000068 break;
69 case CALLBACKS:
whesse@chromium.org023421e2010-12-21 12:19:12 +000070 PrintF(out, " -type = call backs\n");
71 PrintF(out, " -callback object:\n");
72 GetCallbackObject()->Print(out);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000073 break;
kmillikin@chromium.orgc53e10d2011-05-18 09:12:58 +000074 case HANDLER:
75 PrintF(out, " -type = lookup proxy\n");
76 break;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000077 case INTERCEPTOR:
whesse@chromium.org023421e2010-12-21 12:19:12 +000078 PrintF(out, " -type = lookup interceptor\n");
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000079 break;
yangguo@chromium.org99aa4902012-07-06 16:21:55 +000080 case TRANSITION:
81 switch (GetTransitionDetails().type()) {
82 case FIELD:
83 PrintF(out, " -type = map transition\n");
84 PrintF(out, " -map:\n");
85 GetTransitionMap()->Print(out);
86 PrintF(out, "\n");
87 return;
88 case CONSTANT_FUNCTION:
89 PrintF(out, " -type = constant property transition\n");
90 PrintF(out, " -map:\n");
91 GetTransitionMap()->Print(out);
92 PrintF(out, "\n");
93 return;
94 case CALLBACKS:
95 PrintF(out, " -type = callbacks transition\n");
96 PrintF(out, " -callback object:\n");
97 GetCallbackObject()->Print(out);
98 return;
99 default:
100 UNREACHABLE();
101 return;
102 }
jkummerow@chromium.org7a6fc812012-06-27 11:12:38 +0000103 case NONEXISTENT:
104 UNREACHABLE();
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000105 break;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000106 }
107}
108
109
whesse@chromium.org023421e2010-12-21 12:19:12 +0000110void Descriptor::Print(FILE* out) {
111 PrintF(out, "Descriptor ");
112 GetKey()->ShortPrint(out);
113 PrintF(out, " @ ");
114 GetValue()->ShortPrint(out);
115 PrintF(out, " %d\n", GetDetails().index());
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000116}
117
118
119#endif
120
121
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000122} } // namespace v8::internal