Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1 | // 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 | #include "v8.h" |
| 29 | |
| 30 | #include "disassembler.h" |
| 31 | #include "disasm.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 32 | #include "jsregexp.h" |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 33 | #include "objects-visiting.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 34 | |
| 35 | namespace v8 { |
| 36 | namespace internal { |
| 37 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 38 | #ifdef OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 39 | |
| 40 | static const char* TypeToString(InstanceType type); |
| 41 | |
| 42 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 43 | void MaybeObject::Print(FILE* out) { |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 44 | Object* this_as_object; |
| 45 | if (ToObject(&this_as_object)) { |
| 46 | if (this_as_object->IsSmi()) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 47 | Smi::cast(this_as_object)->SmiPrint(out); |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 48 | } else { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 49 | HeapObject::cast(this_as_object)->HeapObjectPrint(out); |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 50 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 51 | } else { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 52 | Failure::cast(this)->FailurePrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 53 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 54 | Flush(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 58 | void MaybeObject::PrintLn(FILE* out) { |
| 59 | Print(out); |
| 60 | PrintF(out, "\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 61 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 62 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 63 | |
| 64 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 65 | #ifdef DEBUG |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 66 | void MaybeObject::Verify() { |
| 67 | Object* this_as_object; |
| 68 | if (ToObject(&this_as_object)) { |
| 69 | if (this_as_object->IsSmi()) { |
| 70 | Smi::cast(this_as_object)->SmiVerify(); |
| 71 | } else { |
| 72 | HeapObject::cast(this_as_object)->HeapObjectVerify(); |
| 73 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 74 | } else { |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 75 | Failure::cast(this)->FailureVerify(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 76 | } |
| 77 | } |
| 78 | |
| 79 | |
| 80 | void Object::VerifyPointer(Object* p) { |
| 81 | if (p->IsHeapObject()) { |
| 82 | HeapObject::VerifyHeapPointer(p); |
| 83 | } else { |
| 84 | ASSERT(p->IsSmi()); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | |
| 89 | void Smi::SmiVerify() { |
| 90 | ASSERT(IsSmi()); |
| 91 | } |
| 92 | |
| 93 | |
| 94 | void Failure::FailureVerify() { |
| 95 | ASSERT(IsFailure()); |
| 96 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 97 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 98 | |
| 99 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 100 | #ifdef OBJECT_PRINT |
| 101 | void HeapObject::PrintHeader(FILE* out, const char* id) { |
| 102 | PrintF(out, "%p: [%s]\n", reinterpret_cast<void*>(this), id); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 106 | void HeapObject::HeapObjectPrint(FILE* out) { |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 107 | InstanceType instance_type = map()->instance_type(); |
| 108 | |
| 109 | HandleScope scope; |
| 110 | if (instance_type < FIRST_NONSTRING_TYPE) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 111 | String::cast(this)->StringPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 112 | return; |
| 113 | } |
| 114 | |
| 115 | switch (instance_type) { |
| 116 | case MAP_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 117 | Map::cast(this)->MapPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 118 | break; |
| 119 | case HEAP_NUMBER_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 120 | HeapNumber::cast(this)->HeapNumberPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 121 | break; |
| 122 | case FIXED_ARRAY_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 123 | FixedArray::cast(this)->FixedArrayPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 124 | break; |
| 125 | case BYTE_ARRAY_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 126 | ByteArray::cast(this)->ByteArrayPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 127 | break; |
| 128 | case PIXEL_ARRAY_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 129 | PixelArray::cast(this)->PixelArrayPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 130 | break; |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 131 | case EXTERNAL_BYTE_ARRAY_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 132 | ExternalByteArray::cast(this)->ExternalByteArrayPrint(out); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 133 | break; |
| 134 | case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 135 | ExternalUnsignedByteArray::cast(this) |
| 136 | ->ExternalUnsignedByteArrayPrint(out); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 137 | break; |
| 138 | case EXTERNAL_SHORT_ARRAY_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 139 | ExternalShortArray::cast(this)->ExternalShortArrayPrint(out); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 140 | break; |
| 141 | case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 142 | ExternalUnsignedShortArray::cast(this) |
| 143 | ->ExternalUnsignedShortArrayPrint(out); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 144 | break; |
| 145 | case EXTERNAL_INT_ARRAY_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 146 | ExternalIntArray::cast(this)->ExternalIntArrayPrint(out); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 147 | break; |
| 148 | case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 149 | ExternalUnsignedIntArray::cast(this)->ExternalUnsignedIntArrayPrint(out); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 150 | break; |
| 151 | case EXTERNAL_FLOAT_ARRAY_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 152 | ExternalFloatArray::cast(this)->ExternalFloatArrayPrint(out); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 153 | break; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 154 | case FILLER_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 155 | PrintF(out, "filler"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 156 | break; |
| 157 | case JS_OBJECT_TYPE: // fall through |
| 158 | case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
| 159 | case JS_ARRAY_TYPE: |
| 160 | case JS_REGEXP_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 161 | JSObject::cast(this)->JSObjectPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 162 | break; |
| 163 | case ODDBALL_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 164 | Oddball::cast(this)->to_string()->Print(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 165 | break; |
| 166 | case JS_FUNCTION_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 167 | JSFunction::cast(this)->JSFunctionPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 168 | break; |
| 169 | case JS_GLOBAL_PROXY_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 170 | JSGlobalProxy::cast(this)->JSGlobalProxyPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 171 | break; |
| 172 | case JS_GLOBAL_OBJECT_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 173 | JSGlobalObject::cast(this)->JSGlobalObjectPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 174 | break; |
| 175 | case JS_BUILTINS_OBJECT_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 176 | JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 177 | break; |
| 178 | case JS_VALUE_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 179 | PrintF(out, "Value wrapper around:"); |
| 180 | JSValue::cast(this)->value()->Print(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 181 | break; |
| 182 | case CODE_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 183 | Code::cast(this)->CodePrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 184 | break; |
| 185 | case PROXY_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 186 | Proxy::cast(this)->ProxyPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 187 | break; |
| 188 | case SHARED_FUNCTION_INFO_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 189 | SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 190 | break; |
| 191 | case JS_GLOBAL_PROPERTY_CELL_TYPE: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 192 | JSGlobalPropertyCell::cast(this)->JSGlobalPropertyCellPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 193 | break; |
| 194 | #define MAKE_STRUCT_CASE(NAME, Name, name) \ |
| 195 | case NAME##_TYPE: \ |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 196 | Name::cast(this)->Name##Print(out); \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 197 | break; |
| 198 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 199 | #undef MAKE_STRUCT_CASE |
| 200 | |
| 201 | default: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 202 | PrintF(out, "UNKNOWN TYPE %d", map()->instance_type()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 203 | UNREACHABLE(); |
| 204 | break; |
| 205 | } |
| 206 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 207 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 208 | |
| 209 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 210 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 211 | void HeapObject::HeapObjectVerify() { |
| 212 | InstanceType instance_type = map()->instance_type(); |
| 213 | |
| 214 | if (instance_type < FIRST_NONSTRING_TYPE) { |
| 215 | String::cast(this)->StringVerify(); |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | switch (instance_type) { |
| 220 | case MAP_TYPE: |
| 221 | Map::cast(this)->MapVerify(); |
| 222 | break; |
| 223 | case HEAP_NUMBER_TYPE: |
| 224 | HeapNumber::cast(this)->HeapNumberVerify(); |
| 225 | break; |
| 226 | case FIXED_ARRAY_TYPE: |
| 227 | FixedArray::cast(this)->FixedArrayVerify(); |
| 228 | break; |
| 229 | case BYTE_ARRAY_TYPE: |
| 230 | ByteArray::cast(this)->ByteArrayVerify(); |
| 231 | break; |
| 232 | case PIXEL_ARRAY_TYPE: |
| 233 | PixelArray::cast(this)->PixelArrayVerify(); |
| 234 | break; |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 235 | case EXTERNAL_BYTE_ARRAY_TYPE: |
| 236 | ExternalByteArray::cast(this)->ExternalByteArrayVerify(); |
| 237 | break; |
| 238 | case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
| 239 | ExternalUnsignedByteArray::cast(this)->ExternalUnsignedByteArrayVerify(); |
| 240 | break; |
| 241 | case EXTERNAL_SHORT_ARRAY_TYPE: |
| 242 | ExternalShortArray::cast(this)->ExternalShortArrayVerify(); |
| 243 | break; |
| 244 | case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 245 | ExternalUnsignedShortArray::cast(this)-> |
| 246 | ExternalUnsignedShortArrayVerify(); |
| 247 | break; |
| 248 | case EXTERNAL_INT_ARRAY_TYPE: |
| 249 | ExternalIntArray::cast(this)->ExternalIntArrayVerify(); |
| 250 | break; |
| 251 | case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 252 | ExternalUnsignedIntArray::cast(this)->ExternalUnsignedIntArrayVerify(); |
| 253 | break; |
| 254 | case EXTERNAL_FLOAT_ARRAY_TYPE: |
| 255 | ExternalFloatArray::cast(this)->ExternalFloatArrayVerify(); |
| 256 | break; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 257 | case CODE_TYPE: |
| 258 | Code::cast(this)->CodeVerify(); |
| 259 | break; |
| 260 | case ODDBALL_TYPE: |
| 261 | Oddball::cast(this)->OddballVerify(); |
| 262 | break; |
| 263 | case JS_OBJECT_TYPE: |
| 264 | case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
| 265 | JSObject::cast(this)->JSObjectVerify(); |
| 266 | break; |
| 267 | case JS_VALUE_TYPE: |
| 268 | JSValue::cast(this)->JSValueVerify(); |
| 269 | break; |
| 270 | case JS_FUNCTION_TYPE: |
| 271 | JSFunction::cast(this)->JSFunctionVerify(); |
| 272 | break; |
| 273 | case JS_GLOBAL_PROXY_TYPE: |
| 274 | JSGlobalProxy::cast(this)->JSGlobalProxyVerify(); |
| 275 | break; |
| 276 | case JS_GLOBAL_OBJECT_TYPE: |
| 277 | JSGlobalObject::cast(this)->JSGlobalObjectVerify(); |
| 278 | break; |
| 279 | case JS_BUILTINS_OBJECT_TYPE: |
| 280 | JSBuiltinsObject::cast(this)->JSBuiltinsObjectVerify(); |
| 281 | break; |
| 282 | case JS_GLOBAL_PROPERTY_CELL_TYPE: |
| 283 | JSGlobalPropertyCell::cast(this)->JSGlobalPropertyCellVerify(); |
| 284 | break; |
| 285 | case JS_ARRAY_TYPE: |
| 286 | JSArray::cast(this)->JSArrayVerify(); |
| 287 | break; |
| 288 | case JS_REGEXP_TYPE: |
| 289 | JSRegExp::cast(this)->JSRegExpVerify(); |
| 290 | break; |
| 291 | case FILLER_TYPE: |
| 292 | break; |
| 293 | case PROXY_TYPE: |
| 294 | Proxy::cast(this)->ProxyVerify(); |
| 295 | break; |
| 296 | case SHARED_FUNCTION_INFO_TYPE: |
| 297 | SharedFunctionInfo::cast(this)->SharedFunctionInfoVerify(); |
| 298 | break; |
| 299 | |
| 300 | #define MAKE_STRUCT_CASE(NAME, Name, name) \ |
| 301 | case NAME##_TYPE: \ |
| 302 | Name::cast(this)->Name##Verify(); \ |
| 303 | break; |
| 304 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 305 | #undef MAKE_STRUCT_CASE |
| 306 | |
| 307 | default: |
| 308 | UNREACHABLE(); |
| 309 | break; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | |
| 314 | void HeapObject::VerifyHeapPointer(Object* p) { |
| 315 | ASSERT(p->IsHeapObject()); |
| 316 | ASSERT(Heap::Contains(HeapObject::cast(p))); |
| 317 | } |
| 318 | |
| 319 | |
| 320 | void HeapNumber::HeapNumberVerify() { |
| 321 | ASSERT(IsHeapNumber()); |
| 322 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 323 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 324 | |
| 325 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 326 | #ifdef OBJECT_PRINT |
| 327 | void ByteArray::ByteArrayPrint(FILE* out) { |
| 328 | PrintF(out, "byte array, data starts at %p", GetDataStartAddress()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 332 | void PixelArray::PixelArrayPrint(FILE* out) { |
| 333 | PrintF(out, "pixel array"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 337 | void ExternalByteArray::ExternalByteArrayPrint(FILE* out) { |
| 338 | PrintF(out, "external byte array"); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 342 | void ExternalUnsignedByteArray::ExternalUnsignedByteArrayPrint(FILE* out) { |
| 343 | PrintF(out, "external unsigned byte array"); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 347 | void ExternalShortArray::ExternalShortArrayPrint(FILE* out) { |
| 348 | PrintF(out, "external short array"); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 352 | void ExternalUnsignedShortArray::ExternalUnsignedShortArrayPrint(FILE* out) { |
| 353 | PrintF(out, "external unsigned short array"); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 357 | void ExternalIntArray::ExternalIntArrayPrint(FILE* out) { |
| 358 | PrintF(out, "external int array"); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 362 | void ExternalUnsignedIntArray::ExternalUnsignedIntArrayPrint(FILE* out) { |
| 363 | PrintF(out, "external unsigned int array"); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 367 | void ExternalFloatArray::ExternalFloatArrayPrint(FILE* out) { |
| 368 | PrintF(out, "external float array"); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 369 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 370 | #endif // OBJECT_PRINT |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 371 | |
| 372 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 373 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 374 | void ByteArray::ByteArrayVerify() { |
| 375 | ASSERT(IsByteArray()); |
| 376 | } |
| 377 | |
| 378 | |
| 379 | void PixelArray::PixelArrayVerify() { |
| 380 | ASSERT(IsPixelArray()); |
| 381 | } |
| 382 | |
| 383 | |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 384 | void ExternalByteArray::ExternalByteArrayVerify() { |
| 385 | ASSERT(IsExternalByteArray()); |
| 386 | } |
| 387 | |
| 388 | |
| 389 | void ExternalUnsignedByteArray::ExternalUnsignedByteArrayVerify() { |
| 390 | ASSERT(IsExternalUnsignedByteArray()); |
| 391 | } |
| 392 | |
| 393 | |
| 394 | void ExternalShortArray::ExternalShortArrayVerify() { |
| 395 | ASSERT(IsExternalShortArray()); |
| 396 | } |
| 397 | |
| 398 | |
| 399 | void ExternalUnsignedShortArray::ExternalUnsignedShortArrayVerify() { |
| 400 | ASSERT(IsExternalUnsignedShortArray()); |
| 401 | } |
| 402 | |
| 403 | |
| 404 | void ExternalIntArray::ExternalIntArrayVerify() { |
| 405 | ASSERT(IsExternalIntArray()); |
| 406 | } |
| 407 | |
| 408 | |
| 409 | void ExternalUnsignedIntArray::ExternalUnsignedIntArrayVerify() { |
| 410 | ASSERT(IsExternalUnsignedIntArray()); |
| 411 | } |
| 412 | |
| 413 | |
| 414 | void ExternalFloatArray::ExternalFloatArrayVerify() { |
| 415 | ASSERT(IsExternalFloatArray()); |
| 416 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 417 | #endif // DEBUG |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 418 | |
| 419 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 420 | #ifdef OBJECT_PRINT |
| 421 | void JSObject::PrintProperties(FILE* out) { |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 422 | if (HasFastProperties()) { |
| 423 | DescriptorArray* descs = map()->instance_descriptors(); |
| 424 | for (int i = 0; i < descs->number_of_descriptors(); i++) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 425 | PrintF(out, " "); |
| 426 | descs->GetKey(i)->StringPrint(out); |
| 427 | PrintF(out, ": "); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 428 | switch (descs->GetType(i)) { |
| 429 | case FIELD: { |
| 430 | int index = descs->GetFieldIndex(i); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 431 | FastPropertyAt(index)->ShortPrint(out); |
| 432 | PrintF(out, " (field at offset %d)\n", index); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 433 | break; |
| 434 | } |
| 435 | case CONSTANT_FUNCTION: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 436 | descs->GetConstantFunction(i)->ShortPrint(out); |
| 437 | PrintF(out, " (constant function)\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 438 | break; |
| 439 | case CALLBACKS: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 440 | descs->GetCallbacksObject(i)->ShortPrint(out); |
| 441 | PrintF(out, " (callback)\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 442 | break; |
| 443 | case MAP_TRANSITION: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 444 | PrintF(out, " (map transition)\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 445 | break; |
| 446 | case CONSTANT_TRANSITION: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 447 | PrintF(out, " (constant transition)\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 448 | break; |
| 449 | case NULL_DESCRIPTOR: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 450 | PrintF(out, " (null descriptor)\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 451 | break; |
| 452 | default: |
| 453 | UNREACHABLE(); |
| 454 | break; |
| 455 | } |
| 456 | } |
| 457 | } else { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 458 | property_dictionary()->Print(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 459 | } |
| 460 | } |
| 461 | |
| 462 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 463 | void JSObject::PrintElements(FILE* out) { |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 464 | switch (GetElementsKind()) { |
| 465 | case FAST_ELEMENTS: { |
| 466 | // Print in array notation for non-sparse arrays. |
| 467 | FixedArray* p = FixedArray::cast(elements()); |
| 468 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 469 | PrintF(out, " %d: ", i); |
| 470 | p->get(i)->ShortPrint(out); |
| 471 | PrintF(out, "\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 472 | } |
| 473 | break; |
| 474 | } |
| 475 | case PIXEL_ELEMENTS: { |
| 476 | PixelArray* p = PixelArray::cast(elements()); |
| 477 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 478 | PrintF(out, " %d: %d\n", i, p->get(i)); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 479 | } |
| 480 | break; |
| 481 | } |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 482 | case EXTERNAL_BYTE_ELEMENTS: { |
| 483 | ExternalByteArray* p = ExternalByteArray::cast(elements()); |
| 484 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 485 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 486 | } |
| 487 | break; |
| 488 | } |
| 489 | case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { |
| 490 | ExternalUnsignedByteArray* p = |
| 491 | ExternalUnsignedByteArray::cast(elements()); |
| 492 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 493 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 494 | } |
| 495 | break; |
| 496 | } |
| 497 | case EXTERNAL_SHORT_ELEMENTS: { |
| 498 | ExternalShortArray* p = ExternalShortArray::cast(elements()); |
| 499 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 500 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 501 | } |
| 502 | break; |
| 503 | } |
| 504 | case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: { |
| 505 | ExternalUnsignedShortArray* p = |
| 506 | ExternalUnsignedShortArray::cast(elements()); |
| 507 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 508 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 509 | } |
| 510 | break; |
| 511 | } |
| 512 | case EXTERNAL_INT_ELEMENTS: { |
| 513 | ExternalIntArray* p = ExternalIntArray::cast(elements()); |
| 514 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 515 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 516 | } |
| 517 | break; |
| 518 | } |
| 519 | case EXTERNAL_UNSIGNED_INT_ELEMENTS: { |
| 520 | ExternalUnsignedIntArray* p = |
| 521 | ExternalUnsignedIntArray::cast(elements()); |
| 522 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 523 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 524 | } |
| 525 | break; |
| 526 | } |
| 527 | case EXTERNAL_FLOAT_ELEMENTS: { |
| 528 | ExternalFloatArray* p = ExternalFloatArray::cast(elements()); |
| 529 | for (int i = 0; i < p->length(); i++) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 530 | PrintF(out, " %d: %f\n", i, p->get(i)); |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 531 | } |
| 532 | break; |
| 533 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 534 | case DICTIONARY_ELEMENTS: |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 535 | elements()->Print(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 536 | break; |
| 537 | default: |
| 538 | UNREACHABLE(); |
| 539 | break; |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 544 | void JSObject::JSObjectPrint(FILE* out) { |
| 545 | PrintF(out, "%p: [JSObject]\n", reinterpret_cast<void*>(this)); |
| 546 | PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map())); |
| 547 | PrintF(out, " - prototype = %p\n", reinterpret_cast<void*>(GetPrototype())); |
| 548 | PrintF(out, " {\n"); |
| 549 | PrintProperties(out); |
| 550 | PrintElements(out); |
| 551 | PrintF(out, " }\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 552 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 553 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 554 | |
| 555 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 556 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 557 | void JSObject::JSObjectVerify() { |
| 558 | VerifyHeapPointer(properties()); |
| 559 | VerifyHeapPointer(elements()); |
| 560 | if (HasFastProperties()) { |
| 561 | CHECK_EQ(map()->unused_property_fields(), |
| 562 | (map()->inobject_properties() + properties()->length() - |
| 563 | map()->NextFreePropertyIndex())); |
| 564 | } |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 565 | ASSERT(map()->has_fast_elements() == |
Iain Merrick | 7568138 | 2010-08-19 15:07:18 +0100 | [diff] [blame] | 566 | (elements()->map() == Heap::fixed_array_map() || |
| 567 | elements()->map() == Heap::fixed_cow_array_map())); |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 568 | ASSERT(map()->has_fast_elements() == HasFastElements()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 569 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 570 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 571 | |
| 572 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 573 | #ifdef OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 574 | static const char* TypeToString(InstanceType type) { |
| 575 | switch (type) { |
| 576 | case INVALID_TYPE: return "INVALID"; |
| 577 | case MAP_TYPE: return "MAP"; |
| 578 | case HEAP_NUMBER_TYPE: return "HEAP_NUMBER"; |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 579 | case SYMBOL_TYPE: return "SYMBOL"; |
| 580 | case ASCII_SYMBOL_TYPE: return "ASCII_SYMBOL"; |
| 581 | case CONS_SYMBOL_TYPE: return "CONS_SYMBOL"; |
| 582 | case CONS_ASCII_SYMBOL_TYPE: return "CONS_ASCII_SYMBOL"; |
| 583 | case EXTERNAL_ASCII_SYMBOL_TYPE: |
Kristian Monsen | 9dcf7e2 | 2010-06-28 14:14:28 +0100 | [diff] [blame] | 584 | case EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE: |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 585 | case EXTERNAL_SYMBOL_TYPE: return "EXTERNAL_SYMBOL"; |
| 586 | case ASCII_STRING_TYPE: return "ASCII_STRING"; |
| 587 | case STRING_TYPE: return "TWO_BYTE_STRING"; |
| 588 | case CONS_STRING_TYPE: |
| 589 | case CONS_ASCII_STRING_TYPE: return "CONS_STRING"; |
| 590 | case EXTERNAL_ASCII_STRING_TYPE: |
Kristian Monsen | 9dcf7e2 | 2010-06-28 14:14:28 +0100 | [diff] [blame] | 591 | case EXTERNAL_STRING_WITH_ASCII_DATA_TYPE: |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 592 | case EXTERNAL_STRING_TYPE: return "EXTERNAL_STRING"; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 593 | case FIXED_ARRAY_TYPE: return "FIXED_ARRAY"; |
| 594 | case BYTE_ARRAY_TYPE: return "BYTE_ARRAY"; |
| 595 | case PIXEL_ARRAY_TYPE: return "PIXEL_ARRAY"; |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 596 | case EXTERNAL_BYTE_ARRAY_TYPE: return "EXTERNAL_BYTE_ARRAY"; |
| 597 | case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
| 598 | return "EXTERNAL_UNSIGNED_BYTE_ARRAY"; |
| 599 | case EXTERNAL_SHORT_ARRAY_TYPE: return "EXTERNAL_SHORT_ARRAY"; |
| 600 | case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 601 | return "EXTERNAL_UNSIGNED_SHORT_ARRAY"; |
| 602 | case EXTERNAL_INT_ARRAY_TYPE: return "EXTERNAL_INT_ARRAY"; |
| 603 | case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 604 | return "EXTERNAL_UNSIGNED_INT_ARRAY"; |
| 605 | case EXTERNAL_FLOAT_ARRAY_TYPE: return "EXTERNAL_FLOAT_ARRAY"; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 606 | case FILLER_TYPE: return "FILLER"; |
| 607 | case JS_OBJECT_TYPE: return "JS_OBJECT"; |
| 608 | case JS_CONTEXT_EXTENSION_OBJECT_TYPE: return "JS_CONTEXT_EXTENSION_OBJECT"; |
| 609 | case ODDBALL_TYPE: return "ODDBALL"; |
| 610 | case JS_GLOBAL_PROPERTY_CELL_TYPE: return "JS_GLOBAL_PROPERTY_CELL"; |
| 611 | case SHARED_FUNCTION_INFO_TYPE: return "SHARED_FUNCTION_INFO"; |
| 612 | case JS_FUNCTION_TYPE: return "JS_FUNCTION"; |
| 613 | case CODE_TYPE: return "CODE"; |
| 614 | case JS_ARRAY_TYPE: return "JS_ARRAY"; |
| 615 | case JS_REGEXP_TYPE: return "JS_REGEXP"; |
| 616 | case JS_VALUE_TYPE: return "JS_VALUE"; |
| 617 | case JS_GLOBAL_OBJECT_TYPE: return "JS_GLOBAL_OBJECT"; |
| 618 | case JS_BUILTINS_OBJECT_TYPE: return "JS_BUILTINS_OBJECT"; |
| 619 | case JS_GLOBAL_PROXY_TYPE: return "JS_GLOBAL_PROXY"; |
| 620 | case PROXY_TYPE: return "PROXY"; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 621 | #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: return #NAME; |
| 622 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 623 | #undef MAKE_STRUCT_CASE |
| 624 | } |
| 625 | return "UNKNOWN"; |
| 626 | } |
| 627 | |
| 628 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 629 | void Map::MapPrint(FILE* out) { |
| 630 | HeapObject::PrintHeader(out, "Map"); |
| 631 | PrintF(out, " - type: %s\n", TypeToString(instance_type())); |
| 632 | PrintF(out, " - instance size: %d\n", instance_size()); |
| 633 | PrintF(out, " - inobject properties: %d\n", inobject_properties()); |
| 634 | PrintF(out, " - pre-allocated property fields: %d\n", |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 635 | pre_allocated_property_fields()); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 636 | PrintF(out, " - unused property fields: %d\n", unused_property_fields()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 637 | if (is_hidden_prototype()) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 638 | PrintF(out, " - hidden_prototype\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 639 | } |
| 640 | if (has_named_interceptor()) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 641 | PrintF(out, " - named_interceptor\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 642 | } |
| 643 | if (has_indexed_interceptor()) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 644 | PrintF(out, " - indexed_interceptor\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 645 | } |
| 646 | if (is_undetectable()) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 647 | PrintF(out, " - undetectable\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 648 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 649 | if (has_instance_call_handler()) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 650 | PrintF(out, " - instance_call_handler\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 651 | } |
| 652 | if (is_access_check_needed()) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 653 | PrintF(out, " - access_check_needed\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 654 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 655 | PrintF(out, " - instance descriptors: "); |
| 656 | instance_descriptors()->ShortPrint(out); |
| 657 | PrintF(out, "\n - prototype: "); |
| 658 | prototype()->ShortPrint(out); |
| 659 | PrintF(out, "\n - constructor: "); |
| 660 | constructor()->ShortPrint(out); |
| 661 | PrintF(out, "\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 662 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 663 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 664 | |
| 665 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 666 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 667 | void Map::MapVerify() { |
| 668 | ASSERT(!Heap::InNewSpace(this)); |
| 669 | ASSERT(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE); |
Steve Block | 791712a | 2010-08-27 10:21:07 +0100 | [diff] [blame] | 670 | ASSERT(instance_size() == kVariableSizeSentinel || |
| 671 | (kPointerSize <= instance_size() && |
| 672 | instance_size() < Heap::Capacity())); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 673 | VerifyHeapPointer(prototype()); |
| 674 | VerifyHeapPointer(instance_descriptors()); |
| 675 | } |
| 676 | |
| 677 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 678 | void Map::SharedMapVerify() { |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 679 | MapVerify(); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 680 | ASSERT(is_shared()); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 681 | ASSERT_EQ(Heap::empty_descriptor_array(), instance_descriptors()); |
| 682 | ASSERT_EQ(Heap::empty_fixed_array(), code_cache()); |
| 683 | ASSERT_EQ(0, pre_allocated_property_fields()); |
| 684 | ASSERT_EQ(0, unused_property_fields()); |
| 685 | ASSERT_EQ(StaticVisitorBase::GetVisitorId(instance_type(), instance_size()), |
| 686 | visitor_id()); |
| 687 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 688 | #endif // DEBUG |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 689 | |
| 690 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 691 | #ifdef OBJECT_PRINT |
| 692 | void CodeCache::CodeCachePrint(FILE* out) { |
| 693 | HeapObject::PrintHeader(out, "CodeCache"); |
| 694 | PrintF(out, "\n - default_cache: "); |
| 695 | default_cache()->ShortPrint(out); |
| 696 | PrintF(out, "\n - normal_type_cache: "); |
| 697 | normal_type_cache()->ShortPrint(out); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 698 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 699 | #endif // OBJECT_PRINT |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 700 | |
| 701 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 702 | #ifdef DEBUG |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 703 | void CodeCache::CodeCacheVerify() { |
| 704 | VerifyHeapPointer(default_cache()); |
| 705 | VerifyHeapPointer(normal_type_cache()); |
| 706 | ASSERT(default_cache()->IsFixedArray()); |
| 707 | ASSERT(normal_type_cache()->IsUndefined() |
| 708 | || normal_type_cache()->IsCodeCacheHashTable()); |
| 709 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 710 | #endif // DEBUG |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 711 | |
| 712 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 713 | #ifdef OBJECT_PRINT |
| 714 | void FixedArray::FixedArrayPrint(FILE* out) { |
| 715 | HeapObject::PrintHeader(out, "FixedArray"); |
| 716 | PrintF(out, " - length: %d", length()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 717 | for (int i = 0; i < length(); i++) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 718 | PrintF(out, "\n [%d]: ", i); |
| 719 | get(i)->ShortPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 720 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 721 | PrintF(out, "\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 722 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 723 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 724 | |
| 725 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 726 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 727 | void FixedArray::FixedArrayVerify() { |
| 728 | for (int i = 0; i < length(); i++) { |
| 729 | Object* e = get(i); |
| 730 | if (e->IsHeapObject()) { |
| 731 | VerifyHeapPointer(e); |
| 732 | } else { |
| 733 | e->Verify(); |
| 734 | } |
| 735 | } |
| 736 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 737 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 738 | |
| 739 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 740 | #ifdef OBJECT_PRINT |
| 741 | void JSValue::JSValuePrint(FILE* out) { |
| 742 | HeapObject::PrintHeader(out, "ValueObject"); |
| 743 | value()->Print(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 744 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 745 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 746 | |
| 747 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 748 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 749 | void JSValue::JSValueVerify() { |
| 750 | Object* v = value(); |
| 751 | if (v->IsHeapObject()) { |
| 752 | VerifyHeapPointer(v); |
| 753 | } |
| 754 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 755 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 756 | |
| 757 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 758 | #ifdef OBJECT_PRINT |
| 759 | void String::StringPrint(FILE* out) { |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 760 | if (StringShape(this).IsSymbol()) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 761 | PrintF(out, "#"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 762 | } else if (StringShape(this).IsCons()) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 763 | PrintF(out, "c\""); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 764 | } else { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 765 | PrintF(out, "\""); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 766 | } |
| 767 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 768 | const char truncated_epilogue[] = "...<truncated>"; |
| 769 | int len = length(); |
| 770 | if (!FLAG_use_verbose_printer) { |
| 771 | if (len > 100) { |
| 772 | len = 100 - sizeof(truncated_epilogue); |
| 773 | } |
| 774 | } |
| 775 | for (int i = 0; i < len; i++) { |
| 776 | PrintF(out, "%c", Get(i)); |
| 777 | } |
| 778 | if (len != length()) { |
| 779 | PrintF(out, "%s", truncated_epilogue); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 780 | } |
| 781 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 782 | if (!StringShape(this).IsSymbol()) PrintF(out, "\""); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 783 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 784 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 785 | |
| 786 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 787 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 788 | void String::StringVerify() { |
| 789 | CHECK(IsString()); |
| 790 | CHECK(length() >= 0 && length() <= Smi::kMaxValue); |
| 791 | if (IsSymbol()) { |
| 792 | CHECK(!Heap::InNewSpace(this)); |
| 793 | } |
| 794 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 795 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 796 | |
| 797 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 798 | #ifdef OBJECT_PRINT |
| 799 | void JSFunction::JSFunctionPrint(FILE* out) { |
| 800 | HeapObject::PrintHeader(out, "Function"); |
| 801 | PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 802 | PrintF(out, " - initial_map = "); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 803 | if (has_initial_map()) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 804 | initial_map()->ShortPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 805 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 806 | PrintF(out, "\n - shared_info = "); |
| 807 | shared()->ShortPrint(out); |
| 808 | PrintF(out, "\n - name = "); |
| 809 | shared()->name()->Print(out); |
| 810 | PrintF(out, "\n - context = "); |
| 811 | unchecked_context()->ShortPrint(out); |
| 812 | PrintF(out, "\n - code = "); |
| 813 | code()->ShortPrint(out); |
| 814 | PrintF(out, "\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 815 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 816 | PrintProperties(out); |
| 817 | PrintElements(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 818 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 819 | PrintF(out, "\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 820 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 821 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 822 | |
| 823 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 824 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 825 | void JSFunction::JSFunctionVerify() { |
| 826 | CHECK(IsJSFunction()); |
| 827 | VerifyObjectField(kPrototypeOrInitialMapOffset); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 828 | VerifyObjectField(kNextFunctionLinkOffset); |
| 829 | CHECK(next_function_link()->IsUndefined() || |
| 830 | next_function_link()->IsJSFunction()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 831 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 832 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 833 | |
| 834 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 835 | #ifdef OBJECT_PRINT |
| 836 | void SharedFunctionInfo::SharedFunctionInfoPrint(FILE* out) { |
| 837 | HeapObject::PrintHeader(out, "SharedFunctionInfo"); |
| 838 | PrintF(out, " - name: "); |
| 839 | name()->ShortPrint(out); |
| 840 | PrintF(out, "\n - expected_nof_properties: %d", expected_nof_properties()); |
| 841 | PrintF(out, "\n - instance class name = "); |
| 842 | instance_class_name()->Print(out); |
| 843 | PrintF(out, "\n - code = "); |
| 844 | code()->ShortPrint(out); |
| 845 | PrintF(out, "\n - source code = "); |
| 846 | GetSourceCode()->ShortPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 847 | // Script files are often large, hard to read. |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 848 | // PrintF(out, "\n - script ="); |
| 849 | // script()->Print(out); |
| 850 | PrintF(out, "\n - function token position = %d", function_token_position()); |
| 851 | PrintF(out, "\n - start position = %d", start_position()); |
| 852 | PrintF(out, "\n - end position = %d", end_position()); |
| 853 | PrintF(out, "\n - is expression = %d", is_expression()); |
| 854 | PrintF(out, "\n - debug info = "); |
| 855 | debug_info()->ShortPrint(out); |
| 856 | PrintF(out, "\n - length = %d", length()); |
| 857 | PrintF(out, "\n - has_only_simple_this_property_assignments = %d", |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 858 | has_only_simple_this_property_assignments()); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 859 | PrintF(out, "\n - this_property_assignments = "); |
| 860 | this_property_assignments()->ShortPrint(out); |
| 861 | PrintF(out, "\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 862 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 863 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 864 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 865 | |
| 866 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 867 | void SharedFunctionInfo::SharedFunctionInfoVerify() { |
| 868 | CHECK(IsSharedFunctionInfo()); |
| 869 | VerifyObjectField(kNameOffset); |
| 870 | VerifyObjectField(kCodeOffset); |
Ben Murdoch | 3bec4d2 | 2010-07-22 14:51:16 +0100 | [diff] [blame] | 871 | VerifyObjectField(kScopeInfoOffset); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 872 | VerifyObjectField(kInstanceClassNameOffset); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 873 | VerifyObjectField(kFunctionDataOffset); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 874 | VerifyObjectField(kScriptOffset); |
| 875 | VerifyObjectField(kDebugInfoOffset); |
| 876 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 877 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 878 | |
| 879 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 880 | #ifdef OBJECT_PRINT |
| 881 | void JSGlobalProxy::JSGlobalProxyPrint(FILE* out) { |
| 882 | PrintF(out, "global_proxy"); |
| 883 | JSObjectPrint(out); |
| 884 | PrintF(out, "context : "); |
| 885 | context()->ShortPrint(out); |
| 886 | PrintF(out, "\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 887 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 888 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 889 | |
| 890 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 891 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 892 | void JSGlobalProxy::JSGlobalProxyVerify() { |
| 893 | CHECK(IsJSGlobalProxy()); |
| 894 | JSObjectVerify(); |
| 895 | VerifyObjectField(JSGlobalProxy::kContextOffset); |
| 896 | // Make sure that this object has no properties, elements. |
| 897 | CHECK_EQ(0, properties()->length()); |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 898 | CHECK(HasFastElements()); |
| 899 | CHECK_EQ(0, FixedArray::cast(elements())->length()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 900 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 901 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 902 | |
| 903 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 904 | #ifdef OBJECT_PRINT |
| 905 | void JSGlobalObject::JSGlobalObjectPrint(FILE* out) { |
| 906 | PrintF(out, "global "); |
| 907 | JSObjectPrint(out); |
| 908 | PrintF(out, "global context : "); |
| 909 | global_context()->ShortPrint(out); |
| 910 | PrintF(out, "\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 911 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 912 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 913 | |
| 914 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 915 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 916 | void JSGlobalObject::JSGlobalObjectVerify() { |
| 917 | CHECK(IsJSGlobalObject()); |
| 918 | JSObjectVerify(); |
| 919 | for (int i = GlobalObject::kBuiltinsOffset; |
| 920 | i < JSGlobalObject::kSize; |
| 921 | i += kPointerSize) { |
| 922 | VerifyObjectField(i); |
| 923 | } |
| 924 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 925 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 926 | |
| 927 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 928 | #ifdef OBJECT_PRINT |
| 929 | void JSBuiltinsObject::JSBuiltinsObjectPrint(FILE* out) { |
| 930 | PrintF(out, "builtins "); |
| 931 | JSObjectPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 932 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 933 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 934 | |
| 935 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 936 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 937 | void JSBuiltinsObject::JSBuiltinsObjectVerify() { |
| 938 | CHECK(IsJSBuiltinsObject()); |
| 939 | JSObjectVerify(); |
| 940 | for (int i = GlobalObject::kBuiltinsOffset; |
| 941 | i < JSBuiltinsObject::kSize; |
| 942 | i += kPointerSize) { |
| 943 | VerifyObjectField(i); |
| 944 | } |
| 945 | } |
| 946 | |
| 947 | |
| 948 | void Oddball::OddballVerify() { |
| 949 | CHECK(IsOddball()); |
| 950 | VerifyHeapPointer(to_string()); |
| 951 | Object* number = to_number(); |
| 952 | if (number->IsHeapObject()) { |
| 953 | ASSERT(number == Heap::nan_value()); |
| 954 | } else { |
| 955 | ASSERT(number->IsSmi()); |
| 956 | int value = Smi::cast(number)->value(); |
| 957 | ASSERT(value == 0 || value == 1 || value == -1 || |
| 958 | value == -2 || value == -3); |
| 959 | } |
| 960 | } |
| 961 | |
| 962 | |
| 963 | void JSGlobalPropertyCell::JSGlobalPropertyCellVerify() { |
| 964 | CHECK(IsJSGlobalPropertyCell()); |
| 965 | VerifyObjectField(kValueOffset); |
| 966 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 967 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 968 | |
| 969 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 970 | #ifdef OBJECT_PRINT |
| 971 | void JSGlobalPropertyCell::JSGlobalPropertyCellPrint(FILE* out) { |
| 972 | HeapObject::PrintHeader(out, "JSGlobalPropertyCell"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 973 | } |
| 974 | |
| 975 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 976 | void Code::CodePrint(FILE* out) { |
| 977 | HeapObject::PrintHeader(out, "Code"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 978 | #ifdef ENABLE_DISASSEMBLER |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 979 | if (FLAG_use_verbose_printer) { |
| 980 | Disassemble(NULL, out); |
| 981 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 982 | #endif |
| 983 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 984 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 985 | |
| 986 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 987 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 988 | void Code::CodeVerify() { |
| 989 | CHECK(IsAligned(reinterpret_cast<intptr_t>(instruction_start()), |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 990 | kCodeAlignment)); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 991 | Address last_gc_pc = NULL; |
| 992 | for (RelocIterator it(this); !it.done(); it.next()) { |
| 993 | it.rinfo()->Verify(); |
| 994 | // Ensure that GC will not iterate twice over the same pointer. |
| 995 | if (RelocInfo::IsGCRelocMode(it.rinfo()->rmode())) { |
| 996 | CHECK(it.rinfo()->pc() != last_gc_pc); |
| 997 | last_gc_pc = it.rinfo()->pc(); |
| 998 | } |
| 999 | } |
| 1000 | } |
| 1001 | |
| 1002 | |
| 1003 | void JSArray::JSArrayVerify() { |
| 1004 | JSObjectVerify(); |
| 1005 | ASSERT(length()->IsNumber() || length()->IsUndefined()); |
| 1006 | ASSERT(elements()->IsUndefined() || elements()->IsFixedArray()); |
| 1007 | } |
| 1008 | |
| 1009 | |
| 1010 | void JSRegExp::JSRegExpVerify() { |
| 1011 | JSObjectVerify(); |
| 1012 | ASSERT(data()->IsUndefined() || data()->IsFixedArray()); |
| 1013 | switch (TypeTag()) { |
| 1014 | case JSRegExp::ATOM: { |
| 1015 | FixedArray* arr = FixedArray::cast(data()); |
| 1016 | ASSERT(arr->get(JSRegExp::kAtomPatternIndex)->IsString()); |
| 1017 | break; |
| 1018 | } |
| 1019 | case JSRegExp::IRREGEXP: { |
| 1020 | bool is_native = RegExpImpl::UsesNativeRegExp(); |
| 1021 | |
| 1022 | FixedArray* arr = FixedArray::cast(data()); |
| 1023 | Object* ascii_data = arr->get(JSRegExp::kIrregexpASCIICodeIndex); |
| 1024 | // TheHole : Not compiled yet. |
| 1025 | // JSObject: Compilation error. |
| 1026 | // Code/ByteArray: Compiled code. |
| 1027 | ASSERT(ascii_data->IsTheHole() || ascii_data->IsJSObject() || |
| 1028 | (is_native ? ascii_data->IsCode() : ascii_data->IsByteArray())); |
| 1029 | Object* uc16_data = arr->get(JSRegExp::kIrregexpUC16CodeIndex); |
| 1030 | ASSERT(uc16_data->IsTheHole() || ascii_data->IsJSObject() || |
| 1031 | (is_native ? uc16_data->IsCode() : uc16_data->IsByteArray())); |
| 1032 | ASSERT(arr->get(JSRegExp::kIrregexpCaptureCountIndex)->IsSmi()); |
| 1033 | ASSERT(arr->get(JSRegExp::kIrregexpMaxRegisterCountIndex)->IsSmi()); |
| 1034 | break; |
| 1035 | } |
| 1036 | default: |
| 1037 | ASSERT_EQ(JSRegExp::NOT_COMPILED, TypeTag()); |
| 1038 | ASSERT(data()->IsUndefined()); |
| 1039 | break; |
| 1040 | } |
| 1041 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1042 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1043 | |
| 1044 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1045 | #ifdef OBJECT_PRINT |
| 1046 | void Proxy::ProxyPrint(FILE* out) { |
| 1047 | PrintF(out, "proxy to %p", proxy()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1048 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1049 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1050 | |
| 1051 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1052 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1053 | void Proxy::ProxyVerify() { |
| 1054 | ASSERT(IsProxy()); |
| 1055 | } |
| 1056 | |
| 1057 | |
| 1058 | void AccessorInfo::AccessorInfoVerify() { |
| 1059 | CHECK(IsAccessorInfo()); |
| 1060 | VerifyPointer(getter()); |
| 1061 | VerifyPointer(setter()); |
| 1062 | VerifyPointer(name()); |
| 1063 | VerifyPointer(data()); |
| 1064 | VerifyPointer(flag()); |
| 1065 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1066 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1067 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1068 | |
| 1069 | #ifdef OBJECT_PRINT |
| 1070 | void AccessorInfo::AccessorInfoPrint(FILE* out) { |
| 1071 | HeapObject::PrintHeader(out, "AccessorInfo"); |
| 1072 | PrintF(out, "\n - getter: "); |
| 1073 | getter()->ShortPrint(out); |
| 1074 | PrintF(out, "\n - setter: "); |
| 1075 | setter()->ShortPrint(out); |
| 1076 | PrintF(out, "\n - name: "); |
| 1077 | name()->ShortPrint(out); |
| 1078 | PrintF(out, "\n - data: "); |
| 1079 | data()->ShortPrint(out); |
| 1080 | PrintF(out, "\n - flag: "); |
| 1081 | flag()->ShortPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1082 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1083 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1084 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1085 | |
| 1086 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1087 | void AccessCheckInfo::AccessCheckInfoVerify() { |
| 1088 | CHECK(IsAccessCheckInfo()); |
| 1089 | VerifyPointer(named_callback()); |
| 1090 | VerifyPointer(indexed_callback()); |
| 1091 | VerifyPointer(data()); |
| 1092 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1093 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1094 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1095 | |
| 1096 | #ifdef OBJECT_PRINT |
| 1097 | void AccessCheckInfo::AccessCheckInfoPrint(FILE* out) { |
| 1098 | HeapObject::PrintHeader(out, "AccessCheckInfo"); |
| 1099 | PrintF(out, "\n - named_callback: "); |
| 1100 | named_callback()->ShortPrint(out); |
| 1101 | PrintF(out, "\n - indexed_callback: "); |
| 1102 | indexed_callback()->ShortPrint(out); |
| 1103 | PrintF(out, "\n - data: "); |
| 1104 | data()->ShortPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1105 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1106 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1107 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1108 | |
| 1109 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1110 | void InterceptorInfo::InterceptorInfoVerify() { |
| 1111 | CHECK(IsInterceptorInfo()); |
| 1112 | VerifyPointer(getter()); |
| 1113 | VerifyPointer(setter()); |
| 1114 | VerifyPointer(query()); |
| 1115 | VerifyPointer(deleter()); |
| 1116 | VerifyPointer(enumerator()); |
| 1117 | VerifyPointer(data()); |
| 1118 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1119 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1120 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1121 | |
| 1122 | #ifdef OBJECT_PRINT |
| 1123 | void InterceptorInfo::InterceptorInfoPrint(FILE* out) { |
| 1124 | HeapObject::PrintHeader(out, "InterceptorInfo"); |
| 1125 | PrintF(out, "\n - getter: "); |
| 1126 | getter()->ShortPrint(out); |
| 1127 | PrintF(out, "\n - setter: "); |
| 1128 | setter()->ShortPrint(out); |
| 1129 | PrintF(out, "\n - query: "); |
| 1130 | query()->ShortPrint(out); |
| 1131 | PrintF(out, "\n - deleter: "); |
| 1132 | deleter()->ShortPrint(out); |
| 1133 | PrintF(out, "\n - enumerator: "); |
| 1134 | enumerator()->ShortPrint(out); |
| 1135 | PrintF(out, "\n - data: "); |
| 1136 | data()->ShortPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1137 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1138 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1139 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1140 | |
| 1141 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1142 | void CallHandlerInfo::CallHandlerInfoVerify() { |
| 1143 | CHECK(IsCallHandlerInfo()); |
| 1144 | VerifyPointer(callback()); |
| 1145 | VerifyPointer(data()); |
| 1146 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1147 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1148 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1149 | |
| 1150 | #ifdef OBJECT_PRINT |
| 1151 | void CallHandlerInfo::CallHandlerInfoPrint(FILE* out) { |
| 1152 | HeapObject::PrintHeader(out, "CallHandlerInfo"); |
| 1153 | PrintF(out, "\n - callback: "); |
| 1154 | callback()->ShortPrint(out); |
| 1155 | PrintF(out, "\n - data: "); |
| 1156 | data()->ShortPrint(out); |
| 1157 | PrintF(out, "\n - call_stub_cache: "); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1158 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1159 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1160 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1161 | |
| 1162 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1163 | void TemplateInfo::TemplateInfoVerify() { |
| 1164 | VerifyPointer(tag()); |
| 1165 | VerifyPointer(property_list()); |
| 1166 | } |
| 1167 | |
| 1168 | void FunctionTemplateInfo::FunctionTemplateInfoVerify() { |
| 1169 | CHECK(IsFunctionTemplateInfo()); |
| 1170 | TemplateInfoVerify(); |
| 1171 | VerifyPointer(serial_number()); |
| 1172 | VerifyPointer(call_code()); |
| 1173 | VerifyPointer(property_accessors()); |
| 1174 | VerifyPointer(prototype_template()); |
| 1175 | VerifyPointer(parent_template()); |
| 1176 | VerifyPointer(named_property_handler()); |
| 1177 | VerifyPointer(indexed_property_handler()); |
| 1178 | VerifyPointer(instance_template()); |
| 1179 | VerifyPointer(signature()); |
| 1180 | VerifyPointer(access_check_info()); |
| 1181 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1182 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1183 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1184 | |
| 1185 | #ifdef OBJECT_PRINT |
| 1186 | void FunctionTemplateInfo::FunctionTemplateInfoPrint(FILE* out) { |
| 1187 | HeapObject::PrintHeader(out, "FunctionTemplateInfo"); |
| 1188 | PrintF(out, "\n - class name: "); |
| 1189 | class_name()->ShortPrint(out); |
| 1190 | PrintF(out, "\n - tag: "); |
| 1191 | tag()->ShortPrint(out); |
| 1192 | PrintF(out, "\n - property_list: "); |
| 1193 | property_list()->ShortPrint(out); |
| 1194 | PrintF(out, "\n - serial_number: "); |
| 1195 | serial_number()->ShortPrint(out); |
| 1196 | PrintF(out, "\n - call_code: "); |
| 1197 | call_code()->ShortPrint(out); |
| 1198 | PrintF(out, "\n - property_accessors: "); |
| 1199 | property_accessors()->ShortPrint(out); |
| 1200 | PrintF(out, "\n - prototype_template: "); |
| 1201 | prototype_template()->ShortPrint(out); |
| 1202 | PrintF(out, "\n - parent_template: "); |
| 1203 | parent_template()->ShortPrint(out); |
| 1204 | PrintF(out, "\n - named_property_handler: "); |
| 1205 | named_property_handler()->ShortPrint(out); |
| 1206 | PrintF(out, "\n - indexed_property_handler: "); |
| 1207 | indexed_property_handler()->ShortPrint(out); |
| 1208 | PrintF(out, "\n - instance_template: "); |
| 1209 | instance_template()->ShortPrint(out); |
| 1210 | PrintF(out, "\n - signature: "); |
| 1211 | signature()->ShortPrint(out); |
| 1212 | PrintF(out, "\n - access_check_info: "); |
| 1213 | access_check_info()->ShortPrint(out); |
| 1214 | PrintF(out, "\n - hidden_prototype: %s", |
| 1215 | hidden_prototype() ? "true" : "false"); |
| 1216 | PrintF(out, "\n - undetectable: %s", undetectable() ? "true" : "false"); |
| 1217 | PrintF(out, "\n - need_access_check: %s", |
| 1218 | needs_access_check() ? "true" : "false"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1219 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1220 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1221 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1222 | |
| 1223 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1224 | void ObjectTemplateInfo::ObjectTemplateInfoVerify() { |
| 1225 | CHECK(IsObjectTemplateInfo()); |
| 1226 | TemplateInfoVerify(); |
| 1227 | VerifyPointer(constructor()); |
| 1228 | VerifyPointer(internal_field_count()); |
| 1229 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1230 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1231 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1232 | |
| 1233 | #ifdef OBJECT_PRINT |
| 1234 | void ObjectTemplateInfo::ObjectTemplateInfoPrint(FILE* out) { |
| 1235 | HeapObject::PrintHeader(out, "ObjectTemplateInfo"); |
| 1236 | PrintF(out, "\n - constructor: "); |
| 1237 | constructor()->ShortPrint(out); |
| 1238 | PrintF(out, "\n - internal_field_count: "); |
| 1239 | internal_field_count()->ShortPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1240 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1241 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1242 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1243 | |
| 1244 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1245 | void SignatureInfo::SignatureInfoVerify() { |
| 1246 | CHECK(IsSignatureInfo()); |
| 1247 | VerifyPointer(receiver()); |
| 1248 | VerifyPointer(args()); |
| 1249 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1250 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1251 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1252 | |
| 1253 | #ifdef OBJECT_PRINT |
| 1254 | void SignatureInfo::SignatureInfoPrint(FILE* out) { |
| 1255 | HeapObject::PrintHeader(out, "SignatureInfo"); |
| 1256 | PrintF(out, "\n - receiver: "); |
| 1257 | receiver()->ShortPrint(out); |
| 1258 | PrintF(out, "\n - args: "); |
| 1259 | args()->ShortPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1260 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1261 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1262 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1263 | |
| 1264 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1265 | void TypeSwitchInfo::TypeSwitchInfoVerify() { |
| 1266 | CHECK(IsTypeSwitchInfo()); |
| 1267 | VerifyPointer(types()); |
| 1268 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1269 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1270 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1271 | |
| 1272 | #ifdef OBJECT_PRINT |
| 1273 | void TypeSwitchInfo::TypeSwitchInfoPrint(FILE* out) { |
| 1274 | HeapObject::PrintHeader(out, "TypeSwitchInfo"); |
| 1275 | PrintF(out, "\n - types: "); |
| 1276 | types()->ShortPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1277 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1278 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1279 | |
| 1280 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1281 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1282 | void Script::ScriptVerify() { |
| 1283 | CHECK(IsScript()); |
| 1284 | VerifyPointer(source()); |
| 1285 | VerifyPointer(name()); |
| 1286 | line_offset()->SmiVerify(); |
| 1287 | column_offset()->SmiVerify(); |
| 1288 | VerifyPointer(data()); |
| 1289 | VerifyPointer(wrapper()); |
| 1290 | type()->SmiVerify(); |
| 1291 | VerifyPointer(line_ends()); |
| 1292 | VerifyPointer(id()); |
| 1293 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1294 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1295 | |
| 1296 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1297 | #ifdef OBJECT_PRINT |
| 1298 | void Script::ScriptPrint(FILE* out) { |
| 1299 | HeapObject::PrintHeader(out, "Script"); |
| 1300 | PrintF(out, "\n - source: "); |
| 1301 | source()->ShortPrint(out); |
| 1302 | PrintF(out, "\n - name: "); |
| 1303 | name()->ShortPrint(out); |
| 1304 | PrintF(out, "\n - line_offset: "); |
| 1305 | line_offset()->ShortPrint(out); |
| 1306 | PrintF(out, "\n - column_offset: "); |
| 1307 | column_offset()->ShortPrint(out); |
| 1308 | PrintF(out, "\n - type: "); |
| 1309 | type()->ShortPrint(out); |
| 1310 | PrintF(out, "\n - id: "); |
| 1311 | id()->ShortPrint(out); |
| 1312 | PrintF(out, "\n - data: "); |
| 1313 | data()->ShortPrint(out); |
| 1314 | PrintF(out, "\n - context data: "); |
| 1315 | context_data()->ShortPrint(out); |
| 1316 | PrintF(out, "\n - wrapper: "); |
| 1317 | wrapper()->ShortPrint(out); |
| 1318 | PrintF(out, "\n - compilation type: "); |
| 1319 | compilation_type()->ShortPrint(out); |
| 1320 | PrintF(out, "\n - line ends: "); |
| 1321 | line_ends()->ShortPrint(out); |
| 1322 | PrintF(out, "\n - eval from shared: "); |
| 1323 | eval_from_shared()->ShortPrint(out); |
| 1324 | PrintF(out, "\n - eval from instructions offset: "); |
| 1325 | eval_from_instructions_offset()->ShortPrint(out); |
| 1326 | PrintF(out, "\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1327 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1328 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1329 | |
| 1330 | |
| 1331 | #ifdef ENABLE_DEBUGGER_SUPPORT |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1332 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1333 | void DebugInfo::DebugInfoVerify() { |
| 1334 | CHECK(IsDebugInfo()); |
| 1335 | VerifyPointer(shared()); |
| 1336 | VerifyPointer(original_code()); |
| 1337 | VerifyPointer(code()); |
| 1338 | VerifyPointer(break_points()); |
| 1339 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1340 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1341 | |
| 1342 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1343 | #ifdef OBJECT_PRINT |
| 1344 | void DebugInfo::DebugInfoPrint(FILE* out) { |
| 1345 | HeapObject::PrintHeader(out, "DebugInfo"); |
| 1346 | PrintF(out, "\n - shared: "); |
| 1347 | shared()->ShortPrint(out); |
| 1348 | PrintF(out, "\n - original_code: "); |
| 1349 | original_code()->ShortPrint(out); |
| 1350 | PrintF(out, "\n - code: "); |
| 1351 | code()->ShortPrint(out); |
| 1352 | PrintF(out, "\n - break_points: "); |
| 1353 | break_points()->Print(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1354 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1355 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1356 | |
| 1357 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1358 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1359 | void BreakPointInfo::BreakPointInfoVerify() { |
| 1360 | CHECK(IsBreakPointInfo()); |
| 1361 | code_position()->SmiVerify(); |
| 1362 | source_position()->SmiVerify(); |
| 1363 | statement_position()->SmiVerify(); |
| 1364 | VerifyPointer(break_point_objects()); |
| 1365 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1366 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1367 | |
| 1368 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1369 | #ifdef OBJECT_PRINT |
| 1370 | void BreakPointInfo::BreakPointInfoPrint(FILE* out) { |
| 1371 | HeapObject::PrintHeader(out, "BreakPointInfo"); |
| 1372 | PrintF(out, "\n - code_position: %d", code_position()->value()); |
| 1373 | PrintF(out, "\n - source_position: %d", source_position()->value()); |
| 1374 | PrintF(out, "\n - statement_position: %d", statement_position()->value()); |
| 1375 | PrintF(out, "\n - break_point_objects: "); |
| 1376 | break_point_objects()->ShortPrint(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1377 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1378 | #endif // OBJECT_PRINT |
| 1379 | #endif // ENABLE_DEBUGGER_SUPPORT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1380 | |
| 1381 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1382 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1383 | void JSObject::IncrementSpillStatistics(SpillInformation* info) { |
| 1384 | info->number_of_objects_++; |
| 1385 | // Named properties |
| 1386 | if (HasFastProperties()) { |
| 1387 | info->number_of_objects_with_fast_properties_++; |
| 1388 | info->number_of_fast_used_fields_ += map()->NextFreePropertyIndex(); |
| 1389 | info->number_of_fast_unused_fields_ += map()->unused_property_fields(); |
| 1390 | } else { |
| 1391 | StringDictionary* dict = property_dictionary(); |
| 1392 | info->number_of_slow_used_properties_ += dict->NumberOfElements(); |
| 1393 | info->number_of_slow_unused_properties_ += |
| 1394 | dict->Capacity() - dict->NumberOfElements(); |
| 1395 | } |
| 1396 | // Indexed properties |
| 1397 | switch (GetElementsKind()) { |
| 1398 | case FAST_ELEMENTS: { |
| 1399 | info->number_of_objects_with_fast_elements_++; |
| 1400 | int holes = 0; |
| 1401 | FixedArray* e = FixedArray::cast(elements()); |
| 1402 | int len = e->length(); |
| 1403 | for (int i = 0; i < len; i++) { |
| 1404 | if (e->get(i) == Heap::the_hole_value()) holes++; |
| 1405 | } |
| 1406 | info->number_of_fast_used_elements_ += len - holes; |
| 1407 | info->number_of_fast_unused_elements_ += holes; |
| 1408 | break; |
| 1409 | } |
| 1410 | case PIXEL_ELEMENTS: { |
| 1411 | info->number_of_objects_with_fast_elements_++; |
| 1412 | PixelArray* e = PixelArray::cast(elements()); |
| 1413 | info->number_of_fast_used_elements_ += e->length(); |
| 1414 | break; |
| 1415 | } |
| 1416 | case DICTIONARY_ELEMENTS: { |
| 1417 | NumberDictionary* dict = element_dictionary(); |
| 1418 | info->number_of_slow_used_elements_ += dict->NumberOfElements(); |
| 1419 | info->number_of_slow_unused_elements_ += |
| 1420 | dict->Capacity() - dict->NumberOfElements(); |
| 1421 | break; |
| 1422 | } |
| 1423 | default: |
| 1424 | UNREACHABLE(); |
| 1425 | break; |
| 1426 | } |
| 1427 | } |
| 1428 | |
| 1429 | |
| 1430 | void JSObject::SpillInformation::Clear() { |
| 1431 | number_of_objects_ = 0; |
| 1432 | number_of_objects_with_fast_properties_ = 0; |
| 1433 | number_of_objects_with_fast_elements_ = 0; |
| 1434 | number_of_fast_used_fields_ = 0; |
| 1435 | number_of_fast_unused_fields_ = 0; |
| 1436 | number_of_slow_used_properties_ = 0; |
| 1437 | number_of_slow_unused_properties_ = 0; |
| 1438 | number_of_fast_used_elements_ = 0; |
| 1439 | number_of_fast_unused_elements_ = 0; |
| 1440 | number_of_slow_used_elements_ = 0; |
| 1441 | number_of_slow_unused_elements_ = 0; |
| 1442 | } |
| 1443 | |
| 1444 | void JSObject::SpillInformation::Print() { |
| 1445 | PrintF("\n JSObject Spill Statistics (#%d):\n", number_of_objects_); |
| 1446 | |
| 1447 | PrintF(" - fast properties (#%d): %d (used) %d (unused)\n", |
| 1448 | number_of_objects_with_fast_properties_, |
| 1449 | number_of_fast_used_fields_, number_of_fast_unused_fields_); |
| 1450 | |
| 1451 | PrintF(" - slow properties (#%d): %d (used) %d (unused)\n", |
| 1452 | number_of_objects_ - number_of_objects_with_fast_properties_, |
| 1453 | number_of_slow_used_properties_, number_of_slow_unused_properties_); |
| 1454 | |
| 1455 | PrintF(" - fast elements (#%d): %d (used) %d (unused)\n", |
| 1456 | number_of_objects_with_fast_elements_, |
| 1457 | number_of_fast_used_elements_, number_of_fast_unused_elements_); |
| 1458 | |
| 1459 | PrintF(" - slow elements (#%d): %d (used) %d (unused)\n", |
| 1460 | number_of_objects_ - number_of_objects_with_fast_elements_, |
| 1461 | number_of_slow_used_elements_, number_of_slow_unused_elements_); |
| 1462 | |
| 1463 | PrintF("\n"); |
| 1464 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1465 | #endif // DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1466 | |
| 1467 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1468 | #ifdef OBJECT_PRINT |
| 1469 | void DescriptorArray::PrintDescriptors(FILE* out) { |
| 1470 | PrintF(out, "Descriptor array %d\n", number_of_descriptors()); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1471 | for (int i = 0; i < number_of_descriptors(); i++) { |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1472 | PrintF(out, " %d: ", i); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1473 | Descriptor desc; |
| 1474 | Get(i, &desc); |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1475 | desc.Print(out); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1476 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1477 | PrintF(out, "\n"); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1478 | } |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1479 | #endif // OBJECT_PRINT |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1480 | |
| 1481 | |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame^] | 1482 | #ifdef DEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1483 | bool DescriptorArray::IsSortedNoDuplicates() { |
| 1484 | String* current_key = NULL; |
| 1485 | uint32_t current = 0; |
| 1486 | for (int i = 0; i < number_of_descriptors(); i++) { |
| 1487 | String* key = GetKey(i); |
| 1488 | if (key == current_key) { |
| 1489 | PrintDescriptors(); |
| 1490 | return false; |
| 1491 | } |
| 1492 | current_key = key; |
| 1493 | uint32_t hash = GetKey(i)->Hash(); |
| 1494 | if (hash < current) { |
| 1495 | PrintDescriptors(); |
| 1496 | return false; |
| 1497 | } |
| 1498 | current = hash; |
| 1499 | } |
| 1500 | return true; |
| 1501 | } |
| 1502 | |
| 1503 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 1504 | void JSFunctionResultCache::JSFunctionResultCacheVerify() { |
| 1505 | JSFunction::cast(get(kFactoryIndex))->Verify(); |
| 1506 | |
| 1507 | int size = Smi::cast(get(kCacheSizeIndex))->value(); |
| 1508 | ASSERT(kEntriesIndex <= size); |
| 1509 | ASSERT(size <= length()); |
| 1510 | ASSERT_EQ(0, size % kEntrySize); |
| 1511 | |
| 1512 | int finger = Smi::cast(get(kFingerIndex))->value(); |
| 1513 | ASSERT(kEntriesIndex <= finger); |
| 1514 | ASSERT(finger < size || finger == kEntriesIndex); |
| 1515 | ASSERT_EQ(0, finger % kEntrySize); |
| 1516 | |
| 1517 | if (FLAG_enable_slow_asserts) { |
| 1518 | for (int i = kEntriesIndex; i < size; i++) { |
| 1519 | ASSERT(!get(i)->IsTheHole()); |
| 1520 | get(i)->Verify(); |
| 1521 | } |
| 1522 | for (int i = size; i < length(); i++) { |
| 1523 | ASSERT(get(i)->IsTheHole()); |
| 1524 | get(i)->Verify(); |
| 1525 | } |
| 1526 | } |
| 1527 | } |
| 1528 | |
| 1529 | |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 1530 | void NormalizedMapCache::NormalizedMapCacheVerify() { |
| 1531 | FixedArray::cast(this)->Verify(); |
| 1532 | if (FLAG_enable_slow_asserts) { |
| 1533 | for (int i = 0; i < length(); i++) { |
| 1534 | Object* e = get(i); |
| 1535 | if (e->IsMap()) { |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 1536 | Map::cast(e)->SharedMapVerify(); |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 1537 | } else { |
| 1538 | ASSERT(e->IsUndefined()); |
| 1539 | } |
| 1540 | } |
| 1541 | } |
| 1542 | } |
| 1543 | |
| 1544 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1545 | #endif // DEBUG |
| 1546 | |
| 1547 | } } // namespace v8::internal |