Home | History | Annotate | Download | only in src
      1 // Copyright 2012 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 namespace v8 {
     31 namespace internal {
     32 
     33 
     34 void LookupResult::Iterate(ObjectVisitor* visitor) {
     35   LookupResult* current = this;  // Could be NULL.
     36   while (current != NULL) {
     37     visitor->VisitPointer(BitCast<Object**>(&current->holder_));
     38     visitor->VisitPointer(BitCast<Object**>(&current->transition_));
     39     current = current->next_;
     40   }
     41 }
     42 
     43 
     44 #ifdef OBJECT_PRINT
     45 void LookupResult::Print(FILE* out) {
     46   if (!IsFound()) {
     47     PrintF(out, "Not Found\n");
     48     return;
     49   }
     50 
     51   PrintF(out, "LookupResult:\n");
     52   PrintF(out, " -cacheable = %s\n", IsCacheable() ? "true" : "false");
     53   PrintF(out, " -attributes = %x\n", GetAttributes());
     54   switch (type()) {
     55     case NORMAL:
     56       PrintF(out, " -type = normal\n");
     57       PrintF(out, " -entry = %d", GetDictionaryEntry());
     58       break;
     59     case CONSTANT:
     60       PrintF(out, " -type = constant\n");
     61       PrintF(out, " -value:\n");
     62       GetConstant()->Print(out);
     63       PrintF(out, "\n");
     64       break;
     65     case FIELD:
     66       PrintF(out, " -type = field\n");
     67       PrintF(out, " -index = %d", GetFieldIndex().field_index());
     68       PrintF(out, "\n");
     69       break;
     70     case CALLBACKS:
     71       PrintF(out, " -type = call backs\n");
     72       PrintF(out, " -callback object:\n");
     73       GetCallbackObject()->Print(out);
     74       break;
     75     case HANDLER:
     76       PrintF(out, " -type = lookup proxy\n");
     77       break;
     78     case INTERCEPTOR:
     79       PrintF(out, " -type = lookup interceptor\n");
     80       break;
     81     case TRANSITION:
     82       switch (GetTransitionDetails().type()) {
     83         case FIELD:
     84           PrintF(out, " -type = map transition\n");
     85           PrintF(out, " -map:\n");
     86           GetTransitionTarget()->Print(out);
     87           PrintF(out, "\n");
     88           return;
     89         case CONSTANT:
     90           PrintF(out, " -type = constant property transition\n");
     91           PrintF(out, " -map:\n");
     92           GetTransitionTarget()->Print(out);
     93           PrintF(out, "\n");
     94           return;
     95         case CALLBACKS:
     96           PrintF(out, " -type = callbacks transition\n");
     97           PrintF(out, " -callback object:\n");
     98           GetCallbackObject()->Print(out);
     99           return;
    100         default:
    101           UNREACHABLE();
    102           return;
    103       }
    104     case NONEXISTENT:
    105       UNREACHABLE();
    106       break;
    107   }
    108 }
    109 
    110 
    111 void Descriptor::Print(FILE* out) {
    112   PrintF(out, "Descriptor ");
    113   GetKey()->ShortPrint(out);
    114   PrintF(out, " @ ");
    115   GetValue()->ShortPrint(out);
    116 }
    117 
    118 
    119 #endif
    120 
    121 
    122 } }  // namespace v8::internal
    123