| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 if (IsNumber()) return context->number_function()->instance_prototype(); | 566 if (IsNumber()) return context->number_function()->instance_prototype(); |
| 567 if (IsString()) return context->string_function()->instance_prototype(); | 567 if (IsString()) return context->string_function()->instance_prototype(); |
| 568 if (IsBoolean()) { | 568 if (IsBoolean()) { |
| 569 return context->boolean_function()->instance_prototype(); | 569 return context->boolean_function()->instance_prototype(); |
| 570 } else { | 570 } else { |
| 571 return heap->null_value(); | 571 return heap->null_value(); |
| 572 } | 572 } |
| 573 } | 573 } |
| 574 | 574 |
| 575 | 575 |
| 576 void Object::ShortPrint() { | 576 void Object::ShortPrint(FILE* out) { |
| 577 HeapStringAllocator allocator; | 577 HeapStringAllocator allocator; |
| 578 StringStream accumulator(&allocator); | 578 StringStream accumulator(&allocator); |
| 579 ShortPrint(&accumulator); | 579 ShortPrint(&accumulator); |
| 580 accumulator.OutputToStdOut(); | 580 accumulator.OutputToFile(out); |
| 581 } | 581 } |
| 582 | 582 |
| 583 | 583 |
| 584 void Object::ShortPrint(StringStream* accumulator) { | 584 void Object::ShortPrint(StringStream* accumulator) { |
| 585 if (IsSmi()) { | 585 if (IsSmi()) { |
| 586 Smi::cast(this)->SmiPrint(accumulator); | 586 Smi::cast(this)->SmiPrint(accumulator); |
| 587 } else if (IsFailure()) { | 587 } else if (IsFailure()) { |
| 588 Failure::cast(this)->FailurePrint(accumulator); | 588 Failure::cast(this)->FailurePrint(accumulator); |
| 589 } else { | 589 } else { |
| 590 HeapObject::cast(this)->HeapObjectShortPrint(accumulator); | 590 HeapObject::cast(this)->HeapObjectShortPrint(accumulator); |
| 591 } | 591 } |
| 592 } | 592 } |
| 593 | 593 |
| 594 | 594 |
| 595 void Smi::SmiPrint() { | 595 void Smi::SmiPrint(FILE* out) { |
| 596 PrintF("%d", value()); | 596 PrintF(out, "%d", value()); |
| 597 } | 597 } |
| 598 | 598 |
| 599 | 599 |
| 600 void Smi::SmiPrint(StringStream* accumulator) { | 600 void Smi::SmiPrint(StringStream* accumulator) { |
| 601 accumulator->Add("%d", value()); | 601 accumulator->Add("%d", value()); |
| 602 } | 602 } |
| 603 | 603 |
| 604 | 604 |
| 605 void Failure::FailurePrint(StringStream* accumulator) { | 605 void Failure::FailurePrint(StringStream* accumulator) { |
| 606 accumulator->Add("Failure(%p)", reinterpret_cast<void*>(value())); | 606 accumulator->Add("Failure(%p)", reinterpret_cast<void*>(value())); |
| 607 } | 607 } |
| 608 | 608 |
| 609 | 609 |
| 610 void Failure::FailurePrint() { | 610 void Failure::FailurePrint(FILE* out) { |
| 611 PrintF("Failure(%p)", reinterpret_cast<void*>(value())); | 611 PrintF(out, "Failure(%p)", reinterpret_cast<void*>(value())); |
| 612 } | 612 } |
| 613 | 613 |
| 614 | 614 |
| 615 // Should a word be prefixed by 'a' or 'an' in order to read naturally in | 615 // Should a word be prefixed by 'a' or 'an' in order to read naturally in |
| 616 // English? Returns false for non-ASCII or words that don't start with | 616 // English? Returns false for non-ASCII or words that don't start with |
| 617 // a capital letter. The a/an rule follows pronunciation in English. | 617 // a capital letter. The a/an rule follows pronunciation in English. |
| 618 // We don't use the BBC's overcorrect "an historic occasion" though if | 618 // We don't use the BBC's overcorrect "an historic occasion" though if |
| 619 // you speak a dialect you may well say "an 'istoric occasion". | 619 // you speak a dialect you may well say "an 'istoric occasion". |
| 620 static bool AnWord(String* str) { | 620 static bool AnWord(String* str) { |
| 621 if (str->length() == 0) return false; // A nothing. | 621 if (str->length() == 0) return false; // A nothing. |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 } | 1157 } |
| 1158 if (u.bits.exp == 0) { | 1158 if (u.bits.exp == 0) { |
| 1159 // Detect +0, and -0 for IEEE double precision floating point. | 1159 // Detect +0, and -0 for IEEE double precision floating point. |
| 1160 if ((u.bits.man_low | u.bits.man_high) == 0) | 1160 if ((u.bits.man_low | u.bits.man_high) == 0) |
| 1161 return GetHeap()->false_value(); | 1161 return GetHeap()->false_value(); |
| 1162 } | 1162 } |
| 1163 return GetHeap()->true_value(); | 1163 return GetHeap()->true_value(); |
| 1164 } | 1164 } |
| 1165 | 1165 |
| 1166 | 1166 |
| 1167 void HeapNumber::HeapNumberPrint() { | 1167 void HeapNumber::HeapNumberPrint(FILE* out) { |
| 1168 PrintF("%.16g", Number()); | 1168 PrintF(out, "%.16g", Number()); |
| 1169 } | 1169 } |
| 1170 | 1170 |
| 1171 | 1171 |
| 1172 void HeapNumber::HeapNumberPrint(StringStream* accumulator) { | 1172 void HeapNumber::HeapNumberPrint(StringStream* accumulator) { |
| 1173 // The Windows version of vsnprintf can allocate when printing a %g string | 1173 // The Windows version of vsnprintf can allocate when printing a %g string |
| 1174 // into a buffer that may not be big enough. We don't want random memory | 1174 // into a buffer that may not be big enough. We don't want random memory |
| 1175 // allocation when producing post-crash stack traces, so we print into a | 1175 // allocation when producing post-crash stack traces, so we print into a |
| 1176 // buffer that is plenty big enough for any floating point number, then | 1176 // buffer that is plenty big enough for any floating point number, then |
| 1177 // print that using vsnprintf (which may truncate but never allocate if | 1177 // print that using vsnprintf (which may truncate but never allocate if |
| 1178 // there is no more space in the buffer). | 1178 // there is no more space in the buffer). |
| (...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3157 if (convert_back_to_fast) { | 3157 if (convert_back_to_fast) { |
| 3158 { MaybeObject* maybe_ok = TransformToFastProperties(0); | 3158 { MaybeObject* maybe_ok = TransformToFastProperties(0); |
| 3159 if (!maybe_ok->ToObject(&ok)) return maybe_ok; | 3159 if (!maybe_ok->ToObject(&ok)) return maybe_ok; |
| 3160 } | 3160 } |
| 3161 } | 3161 } |
| 3162 return result; | 3162 return result; |
| 3163 } | 3163 } |
| 3164 | 3164 |
| 3165 MaybeObject* JSObject::DefineAccessor(String* name, | 3165 MaybeObject* JSObject::DefineAccessor(String* name, |
| 3166 bool is_getter, | 3166 bool is_getter, |
| 3167 JSFunction* fun, | 3167 Object* fun, |
| 3168 PropertyAttributes attributes) { | 3168 PropertyAttributes attributes) { |
| 3169 ASSERT(fun->IsJSFunction() || fun->IsUndefined()); |
| 3169 Isolate* isolate = GetIsolate(); | 3170 Isolate* isolate = GetIsolate(); |
| 3170 // Check access rights if needed. | 3171 // Check access rights if needed. |
| 3171 if (IsAccessCheckNeeded() && | 3172 if (IsAccessCheckNeeded() && |
| 3172 !isolate->MayNamedAccess(this, name, v8::ACCESS_SET)) { | 3173 !isolate->MayNamedAccess(this, name, v8::ACCESS_SET)) { |
| 3173 isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET); | 3174 isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET); |
| 3174 return isolate->heap()->undefined_value(); | 3175 return isolate->heap()->undefined_value(); |
| 3175 } | 3176 } |
| 3176 | 3177 |
| 3177 if (IsJSGlobalProxy()) { | 3178 if (IsJSGlobalProxy()) { |
| 3178 Object* proto = GetPrototype(); | 3179 Object* proto = GetPrototype(); |
| (...skipping 2376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5555 return this; | 5556 return this; |
| 5556 } | 5557 } |
| 5557 | 5558 |
| 5558 | 5559 |
| 5559 Object* JSFunction::SetInstanceClassName(String* name) { | 5560 Object* JSFunction::SetInstanceClassName(String* name) { |
| 5560 shared()->set_instance_class_name(name); | 5561 shared()->set_instance_class_name(name); |
| 5561 return this; | 5562 return this; |
| 5562 } | 5563 } |
| 5563 | 5564 |
| 5564 | 5565 |
| 5565 void JSFunction::PrintName() { | 5566 void JSFunction::PrintName(FILE* out) { |
| 5566 SmartPointer<char> name = shared()->DebugName()->ToCString(); | 5567 SmartPointer<char> name = shared()->DebugName()->ToCString(); |
| 5567 PrintF("%s", *name); | 5568 PrintF(out, "%s", *name); |
| 5568 } | 5569 } |
| 5569 | 5570 |
| 5570 | 5571 |
| 5571 Context* JSFunction::GlobalContextFromLiterals(FixedArray* literals) { | 5572 Context* JSFunction::GlobalContextFromLiterals(FixedArray* literals) { |
| 5572 return Context::cast(literals->get(JSFunction::kLiteralGlobalContextIndex)); | 5573 return Context::cast(literals->get(JSFunction::kLiteralGlobalContextIndex)); |
| 5573 } | 5574 } |
| 5574 | 5575 |
| 5575 | 5576 |
| 5576 MaybeObject* Oddball::Initialize(const char* to_string, | 5577 MaybeObject* Oddball::Initialize(const char* to_string, |
| 5577 Object* to_number, | 5578 Object* to_number, |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6099 RelocInfo* info = it.rinfo(); | 6100 RelocInfo* info = it.rinfo(); |
| 6100 Object* object = info->target_object(); | 6101 Object* object = info->target_object(); |
| 6101 if (object->IsMap()) return Map::cast(object); | 6102 if (object->IsMap()) return Map::cast(object); |
| 6102 } | 6103 } |
| 6103 return NULL; | 6104 return NULL; |
| 6104 } | 6105 } |
| 6105 | 6106 |
| 6106 | 6107 |
| 6107 #ifdef ENABLE_DISASSEMBLER | 6108 #ifdef ENABLE_DISASSEMBLER |
| 6108 | 6109 |
| 6109 #ifdef DEBUG | 6110 #ifdef OBJECT_PRINT |
| 6110 | 6111 |
| 6111 void DeoptimizationInputData::DeoptimizationInputDataPrint() { | 6112 void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) { |
| 6112 disasm::NameConverter converter; | 6113 disasm::NameConverter converter; |
| 6113 int deopt_count = DeoptCount(); | 6114 int deopt_count = DeoptCount(); |
| 6114 PrintF("Deoptimization Input Data (deopt points = %d)\n", deopt_count); | 6115 PrintF(out, "Deoptimization Input Data (deopt points = %d)\n", deopt_count); |
| 6115 if (0 == deopt_count) return; | 6116 if (0 == deopt_count) return; |
| 6116 | 6117 |
| 6117 PrintF("%6s %6s %6s %12s\n", "index", "ast id", "argc", "commands"); | 6118 PrintF(out, "%6s %6s %6s %12s\n", "index", "ast id", "argc", "commands"); |
| 6118 for (int i = 0; i < deopt_count; i++) { | 6119 for (int i = 0; i < deopt_count; i++) { |
| 6119 int command_count = 0; | 6120 int command_count = 0; |
| 6120 PrintF("%6d %6d %6d", | 6121 PrintF(out, "%6d %6d %6d", |
| 6121 i, AstId(i)->value(), ArgumentsStackHeight(i)->value()); | 6122 i, AstId(i)->value(), ArgumentsStackHeight(i)->value()); |
| 6122 int translation_index = TranslationIndex(i)->value(); | 6123 int translation_index = TranslationIndex(i)->value(); |
| 6123 TranslationIterator iterator(TranslationByteArray(), translation_index); | 6124 TranslationIterator iterator(TranslationByteArray(), translation_index); |
| 6124 Translation::Opcode opcode = | 6125 Translation::Opcode opcode = |
| 6125 static_cast<Translation::Opcode>(iterator.Next()); | 6126 static_cast<Translation::Opcode>(iterator.Next()); |
| 6126 ASSERT(Translation::BEGIN == opcode); | 6127 ASSERT(Translation::BEGIN == opcode); |
| 6127 int frame_count = iterator.Next(); | 6128 int frame_count = iterator.Next(); |
| 6128 if (FLAG_print_code_verbose) { | 6129 if (FLAG_print_code_verbose) { |
| 6129 PrintF(" %s {count=%d}\n", Translation::StringFor(opcode), frame_count); | 6130 PrintF(out, " %s {count=%d}\n", Translation::StringFor(opcode), |
| 6131 frame_count); |
| 6130 } | 6132 } |
| 6131 | 6133 |
| 6132 for (int i = 0; i < frame_count; ++i) { | 6134 for (int i = 0; i < frame_count; ++i) { |
| 6133 opcode = static_cast<Translation::Opcode>(iterator.Next()); | 6135 opcode = static_cast<Translation::Opcode>(iterator.Next()); |
| 6134 ASSERT(Translation::FRAME == opcode); | 6136 ASSERT(Translation::FRAME == opcode); |
| 6135 int ast_id = iterator.Next(); | 6137 int ast_id = iterator.Next(); |
| 6136 int function_id = iterator.Next(); | 6138 int function_id = iterator.Next(); |
| 6137 JSFunction* function = | 6139 JSFunction* function = |
| 6138 JSFunction::cast(LiteralArray()->get(function_id)); | 6140 JSFunction::cast(LiteralArray()->get(function_id)); |
| 6139 unsigned height = iterator.Next(); | 6141 unsigned height = iterator.Next(); |
| 6140 if (FLAG_print_code_verbose) { | 6142 if (FLAG_print_code_verbose) { |
| 6141 PrintF("%24s %s {ast_id=%d, function=", | 6143 PrintF(out, "%24s %s {ast_id=%d, function=", |
| 6142 "", Translation::StringFor(opcode), ast_id); | 6144 "", Translation::StringFor(opcode), ast_id); |
| 6143 function->PrintName(); | 6145 function->PrintName(out); |
| 6144 PrintF(", height=%u}\n", height); | 6146 PrintF(out, ", height=%u}\n", height); |
| 6145 } | 6147 } |
| 6146 | 6148 |
| 6147 // Size of translation is height plus all incoming arguments including | 6149 // Size of translation is height plus all incoming arguments including |
| 6148 // receiver. | 6150 // receiver. |
| 6149 int size = height + function->shared()->formal_parameter_count() + 1; | 6151 int size = height + function->shared()->formal_parameter_count() + 1; |
| 6150 command_count += size; | 6152 command_count += size; |
| 6151 for (int j = 0; j < size; ++j) { | 6153 for (int j = 0; j < size; ++j) { |
| 6152 opcode = static_cast<Translation::Opcode>(iterator.Next()); | 6154 opcode = static_cast<Translation::Opcode>(iterator.Next()); |
| 6153 if (FLAG_print_code_verbose) { | 6155 if (FLAG_print_code_verbose) { |
| 6154 PrintF("%24s %s ", "", Translation::StringFor(opcode)); | 6156 PrintF(out, "%24s %s ", "", Translation::StringFor(opcode)); |
| 6155 } | 6157 } |
| 6156 | 6158 |
| 6157 if (opcode == Translation::DUPLICATE) { | 6159 if (opcode == Translation::DUPLICATE) { |
| 6158 opcode = static_cast<Translation::Opcode>(iterator.Next()); | 6160 opcode = static_cast<Translation::Opcode>(iterator.Next()); |
| 6159 if (FLAG_print_code_verbose) { | 6161 if (FLAG_print_code_verbose) { |
| 6160 PrintF("%s ", Translation::StringFor(opcode)); | 6162 PrintF(out, "%s ", Translation::StringFor(opcode)); |
| 6161 } | 6163 } |
| 6162 --j; // Two commands share the same frame index. | 6164 --j; // Two commands share the same frame index. |
| 6163 } | 6165 } |
| 6164 | 6166 |
| 6165 switch (opcode) { | 6167 switch (opcode) { |
| 6166 case Translation::BEGIN: | 6168 case Translation::BEGIN: |
| 6167 case Translation::FRAME: | 6169 case Translation::FRAME: |
| 6168 case Translation::DUPLICATE: | 6170 case Translation::DUPLICATE: |
| 6169 UNREACHABLE(); | 6171 UNREACHABLE(); |
| 6170 break; | 6172 break; |
| 6171 | 6173 |
| 6172 case Translation::REGISTER: { | 6174 case Translation::REGISTER: { |
| 6173 int reg_code = iterator.Next(); | 6175 int reg_code = iterator.Next(); |
| 6174 if (FLAG_print_code_verbose) { | 6176 if (FLAG_print_code_verbose) { |
| 6175 PrintF("{input=%s}", converter.NameOfCPURegister(reg_code)); | 6177 PrintF(out, "{input=%s}", converter.NameOfCPURegister(reg_code)); |
| 6176 } | 6178 } |
| 6177 break; | 6179 break; |
| 6178 } | 6180 } |
| 6179 | 6181 |
| 6180 case Translation::INT32_REGISTER: { | 6182 case Translation::INT32_REGISTER: { |
| 6181 int reg_code = iterator.Next(); | 6183 int reg_code = iterator.Next(); |
| 6182 if (FLAG_print_code_verbose) { | 6184 if (FLAG_print_code_verbose) { |
| 6183 PrintF("{input=%s}", converter.NameOfCPURegister(reg_code)); | 6185 PrintF(out, "{input=%s}", converter.NameOfCPURegister(reg_code)); |
| 6184 } | 6186 } |
| 6185 break; | 6187 break; |
| 6186 } | 6188 } |
| 6187 | 6189 |
| 6188 case Translation::DOUBLE_REGISTER: { | 6190 case Translation::DOUBLE_REGISTER: { |
| 6189 int reg_code = iterator.Next(); | 6191 int reg_code = iterator.Next(); |
| 6190 if (FLAG_print_code_verbose) { | 6192 if (FLAG_print_code_verbose) { |
| 6191 PrintF("{input=%s}", | 6193 PrintF(out, "{input=%s}", |
| 6192 DoubleRegister::AllocationIndexToString(reg_code)); | 6194 DoubleRegister::AllocationIndexToString(reg_code)); |
| 6193 } | 6195 } |
| 6194 break; | 6196 break; |
| 6195 } | 6197 } |
| 6196 | 6198 |
| 6197 case Translation::STACK_SLOT: { | 6199 case Translation::STACK_SLOT: { |
| 6198 int input_slot_index = iterator.Next(); | 6200 int input_slot_index = iterator.Next(); |
| 6199 if (FLAG_print_code_verbose) { | 6201 if (FLAG_print_code_verbose) { |
| 6200 PrintF("{input=%d}", input_slot_index); | 6202 PrintF(out, "{input=%d}", input_slot_index); |
| 6201 } | 6203 } |
| 6202 break; | 6204 break; |
| 6203 } | 6205 } |
| 6204 | 6206 |
| 6205 case Translation::INT32_STACK_SLOT: { | 6207 case Translation::INT32_STACK_SLOT: { |
| 6206 int input_slot_index = iterator.Next(); | 6208 int input_slot_index = iterator.Next(); |
| 6207 if (FLAG_print_code_verbose) { | 6209 if (FLAG_print_code_verbose) { |
| 6208 PrintF("{input=%d}", input_slot_index); | 6210 PrintF(out, "{input=%d}", input_slot_index); |
| 6209 } | 6211 } |
| 6210 break; | 6212 break; |
| 6211 } | 6213 } |
| 6212 | 6214 |
| 6213 case Translation::DOUBLE_STACK_SLOT: { | 6215 case Translation::DOUBLE_STACK_SLOT: { |
| 6214 int input_slot_index = iterator.Next(); | 6216 int input_slot_index = iterator.Next(); |
| 6215 if (FLAG_print_code_verbose) { | 6217 if (FLAG_print_code_verbose) { |
| 6216 PrintF("{input=%d}", input_slot_index); | 6218 PrintF(out, "{input=%d}", input_slot_index); |
| 6217 } | 6219 } |
| 6218 break; | 6220 break; |
| 6219 } | 6221 } |
| 6220 | 6222 |
| 6221 case Translation::LITERAL: { | 6223 case Translation::LITERAL: { |
| 6222 unsigned literal_index = iterator.Next(); | 6224 unsigned literal_index = iterator.Next(); |
| 6223 if (FLAG_print_code_verbose) { | 6225 if (FLAG_print_code_verbose) { |
| 6224 PrintF("{literal_id=%u}", literal_index); | 6226 PrintF(out, "{literal_id=%u}", literal_index); |
| 6225 } | 6227 } |
| 6226 break; | 6228 break; |
| 6227 } | 6229 } |
| 6228 | 6230 |
| 6229 case Translation::ARGUMENTS_OBJECT: | 6231 case Translation::ARGUMENTS_OBJECT: |
| 6230 break; | 6232 break; |
| 6231 } | 6233 } |
| 6232 if (FLAG_print_code_verbose) PrintF("\n"); | 6234 if (FLAG_print_code_verbose) PrintF(out, "\n"); |
| 6233 } | 6235 } |
| 6234 } | 6236 } |
| 6235 if (!FLAG_print_code_verbose) PrintF(" %12d\n", command_count); | 6237 if (!FLAG_print_code_verbose) PrintF(out, " %12d\n", command_count); |
| 6236 } | 6238 } |
| 6237 } | 6239 } |
| 6238 | 6240 |
| 6239 | 6241 |
| 6240 void DeoptimizationOutputData::DeoptimizationOutputDataPrint() { | 6242 void DeoptimizationOutputData::DeoptimizationOutputDataPrint(FILE* out) { |
| 6241 PrintF("Deoptimization Output Data (deopt points = %d)\n", | 6243 PrintF(out, "Deoptimization Output Data (deopt points = %d)\n", |
| 6242 this->DeoptPoints()); | 6244 this->DeoptPoints()); |
| 6243 if (this->DeoptPoints() == 0) return; | 6245 if (this->DeoptPoints() == 0) return; |
| 6244 | 6246 |
| 6245 PrintF("%6s %8s %s\n", "ast id", "pc", "state"); | 6247 PrintF("%6s %8s %s\n", "ast id", "pc", "state"); |
| 6246 for (int i = 0; i < this->DeoptPoints(); i++) { | 6248 for (int i = 0; i < this->DeoptPoints(); i++) { |
| 6247 int pc_and_state = this->PcAndState(i)->value(); | 6249 int pc_and_state = this->PcAndState(i)->value(); |
| 6248 PrintF("%6d %8d %s\n", | 6250 PrintF("%6d %8d %s\n", |
| 6249 this->AstId(i)->value(), | 6251 this->AstId(i)->value(), |
| 6250 FullCodeGenerator::PcField::decode(pc_and_state), | 6252 FullCodeGenerator::PcField::decode(pc_and_state), |
| 6251 FullCodeGenerator::State2String( | 6253 FullCodeGenerator::State2String( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6302 case INTERCEPTOR: return "INTERCEPTOR"; | 6304 case INTERCEPTOR: return "INTERCEPTOR"; |
| 6303 case MAP_TRANSITION: return "MAP_TRANSITION"; | 6305 case MAP_TRANSITION: return "MAP_TRANSITION"; |
| 6304 case CONSTANT_TRANSITION: return "CONSTANT_TRANSITION"; | 6306 case CONSTANT_TRANSITION: return "CONSTANT_TRANSITION"; |
| 6305 case NULL_DESCRIPTOR: return "NULL_DESCRIPTOR"; | 6307 case NULL_DESCRIPTOR: return "NULL_DESCRIPTOR"; |
| 6306 } | 6308 } |
| 6307 UNREACHABLE(); | 6309 UNREACHABLE(); |
| 6308 return NULL; | 6310 return NULL; |
| 6309 } | 6311 } |
| 6310 | 6312 |
| 6311 | 6313 |
| 6312 void Code::Disassemble(const char* name) { | 6314 void Code::Disassemble(const char* name, FILE* out) { |
| 6313 PrintF("kind = %s\n", Kind2String(kind())); | 6315 PrintF(out, "kind = %s\n", Kind2String(kind())); |
| 6314 if (is_inline_cache_stub()) { | 6316 if (is_inline_cache_stub()) { |
| 6315 PrintF("ic_state = %s\n", ICState2String(ic_state())); | 6317 PrintF(out, "ic_state = %s\n", ICState2String(ic_state())); |
| 6316 PrintF("ic_in_loop = %d\n", ic_in_loop() == IN_LOOP); | 6318 PrintF(out, "ic_in_loop = %d\n", ic_in_loop() == IN_LOOP); |
| 6317 if (ic_state() == MONOMORPHIC) { | 6319 if (ic_state() == MONOMORPHIC) { |
| 6318 PrintF("type = %s\n", PropertyType2String(type())); | 6320 PrintF(out, "type = %s\n", PropertyType2String(type())); |
| 6319 } | 6321 } |
| 6320 } | 6322 } |
| 6321 if ((name != NULL) && (name[0] != '\0')) { | 6323 if ((name != NULL) && (name[0] != '\0')) { |
| 6322 PrintF("name = %s\n", name); | 6324 PrintF(out, "name = %s\n", name); |
| 6323 } | 6325 } |
| 6324 if (kind() == OPTIMIZED_FUNCTION) { | 6326 if (kind() == OPTIMIZED_FUNCTION) { |
| 6325 PrintF("stack_slots = %d\n", stack_slots()); | 6327 PrintF(out, "stack_slots = %d\n", stack_slots()); |
| 6326 } | 6328 } |
| 6327 | 6329 |
| 6328 PrintF("Instructions (size = %d)\n", instruction_size()); | 6330 PrintF(out, "Instructions (size = %d)\n", instruction_size()); |
| 6329 Disassembler::Decode(NULL, this); | 6331 Disassembler::Decode(out, this); |
| 6330 PrintF("\n"); | 6332 PrintF(out, "\n"); |
| 6331 | 6333 |
| 6332 #ifdef DEBUG | 6334 #ifdef DEBUG |
| 6333 if (kind() == FUNCTION) { | 6335 if (kind() == FUNCTION) { |
| 6334 DeoptimizationOutputData* data = | 6336 DeoptimizationOutputData* data = |
| 6335 DeoptimizationOutputData::cast(this->deoptimization_data()); | 6337 DeoptimizationOutputData::cast(this->deoptimization_data()); |
| 6336 data->DeoptimizationOutputDataPrint(); | 6338 data->DeoptimizationOutputDataPrint(out); |
| 6337 } else if (kind() == OPTIMIZED_FUNCTION) { | 6339 } else if (kind() == OPTIMIZED_FUNCTION) { |
| 6338 DeoptimizationInputData* data = | 6340 DeoptimizationInputData* data = |
| 6339 DeoptimizationInputData::cast(this->deoptimization_data()); | 6341 DeoptimizationInputData::cast(this->deoptimization_data()); |
| 6340 data->DeoptimizationInputDataPrint(); | 6342 data->DeoptimizationInputDataPrint(out); |
| 6341 } | 6343 } |
| 6342 PrintF("\n"); | 6344 PrintF("\n"); |
| 6343 #endif | 6345 #endif |
| 6344 | 6346 |
| 6345 if (kind() == OPTIMIZED_FUNCTION) { | 6347 if (kind() == OPTIMIZED_FUNCTION) { |
| 6346 SafepointTable table(this); | 6348 SafepointTable table(this); |
| 6347 PrintF("Safepoints (size = %u)\n", table.size()); | 6349 PrintF(out, "Safepoints (size = %u)\n", table.size()); |
| 6348 for (unsigned i = 0; i < table.length(); i++) { | 6350 for (unsigned i = 0; i < table.length(); i++) { |
| 6349 unsigned pc_offset = table.GetPcOffset(i); | 6351 unsigned pc_offset = table.GetPcOffset(i); |
| 6350 PrintF("%p %4d ", (instruction_start() + pc_offset), pc_offset); | 6352 PrintF(out, "%p %4d ", (instruction_start() + pc_offset), pc_offset); |
| 6351 table.PrintEntry(i); | 6353 table.PrintEntry(i); |
| 6352 PrintF(" (sp -> fp)"); | 6354 PrintF(out, " (sp -> fp)"); |
| 6353 int deoptimization_index = table.GetDeoptimizationIndex(i); | 6355 int deoptimization_index = table.GetDeoptimizationIndex(i); |
| 6354 if (deoptimization_index != Safepoint::kNoDeoptimizationIndex) { | 6356 if (deoptimization_index != Safepoint::kNoDeoptimizationIndex) { |
| 6355 PrintF(" %6d", deoptimization_index); | 6357 PrintF(out, " %6d", deoptimization_index); |
| 6356 } else { | 6358 } else { |
| 6357 PrintF(" <none>"); | 6359 PrintF(out, " <none>"); |
| 6358 } | 6360 } |
| 6359 PrintF("\n"); | 6361 PrintF(out, "\n"); |
| 6360 } | 6362 } |
| 6361 PrintF("\n"); | 6363 PrintF(out, "\n"); |
| 6362 } else if (kind() == FUNCTION) { | 6364 } else if (kind() == FUNCTION) { |
| 6363 unsigned offset = stack_check_table_start(); | 6365 unsigned offset = stack_check_table_start(); |
| 6364 // If there is no stack check table, the "table start" will at or after | 6366 // If there is no stack check table, the "table start" will at or after |
| 6365 // (due to alignment) the end of the instruction stream. | 6367 // (due to alignment) the end of the instruction stream. |
| 6366 if (static_cast<int>(offset) < instruction_size()) { | 6368 if (static_cast<int>(offset) < instruction_size()) { |
| 6367 unsigned* address = | 6369 unsigned* address = |
| 6368 reinterpret_cast<unsigned*>(instruction_start() + offset); | 6370 reinterpret_cast<unsigned*>(instruction_start() + offset); |
| 6369 unsigned length = address[0]; | 6371 unsigned length = address[0]; |
| 6370 PrintF("Stack checks (size = %u)\n", length); | 6372 PrintF(out, "Stack checks (size = %u)\n", length); |
| 6371 PrintF("ast_id pc_offset\n"); | 6373 PrintF(out, "ast_id pc_offset\n"); |
| 6372 for (unsigned i = 0; i < length; ++i) { | 6374 for (unsigned i = 0; i < length; ++i) { |
| 6373 unsigned index = (2 * i) + 1; | 6375 unsigned index = (2 * i) + 1; |
| 6374 PrintF("%6u %9u\n", address[index], address[index + 1]); | 6376 PrintF(out, "%6u %9u\n", address[index], address[index + 1]); |
| 6375 } | 6377 } |
| 6376 PrintF("\n"); | 6378 PrintF(out, "\n"); |
| 6377 } | 6379 } |
| 6378 } | 6380 } |
| 6379 | 6381 |
| 6380 PrintF("RelocInfo (size = %d)\n", relocation_size()); | 6382 PrintF("RelocInfo (size = %d)\n", relocation_size()); |
| 6381 for (RelocIterator it(this); !it.done(); it.next()) it.rinfo()->Print(); | 6383 for (RelocIterator it(this); !it.done(); it.next()) it.rinfo()->Print(out); |
| 6382 PrintF("\n"); | 6384 PrintF(out, "\n"); |
| 6383 } | 6385 } |
| 6384 #endif // ENABLE_DISASSEMBLER | 6386 #endif // ENABLE_DISASSEMBLER |
| 6385 | 6387 |
| 6386 | 6388 |
| 6387 MaybeObject* JSObject::SetFastElementsCapacityAndLength(int capacity, | 6389 MaybeObject* JSObject::SetFastElementsCapacityAndLength(int capacity, |
| 6388 int length) { | 6390 int length) { |
| 6389 Heap* heap = GetHeap(); | 6391 Heap* heap = GetHeap(); |
| 6390 // We should never end in here with a pixel or external array. | 6392 // We should never end in here with a pixel or external array. |
| 6391 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); | 6393 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); |
| 6392 | 6394 |
| (...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7541 return static_cast<uint32_t>(dictionary->Capacity()) >= | 7543 return static_cast<uint32_t>(dictionary->Capacity()) >= |
| 7542 (length / (2 * NumberDictionary::kEntrySize)); | 7544 (length / (2 * NumberDictionary::kEntrySize)); |
| 7543 } | 7545 } |
| 7544 | 7546 |
| 7545 | 7547 |
| 7546 // Certain compilers request function template instantiation when they | 7548 // Certain compilers request function template instantiation when they |
| 7547 // see the definition of the other template functions in the | 7549 // see the definition of the other template functions in the |
| 7548 // class. This requires us to have the template functions put | 7550 // class. This requires us to have the template functions put |
| 7549 // together, so even though this function belongs in objects-debug.cc, | 7551 // together, so even though this function belongs in objects-debug.cc, |
| 7550 // we keep it here instead to satisfy certain compilers. | 7552 // we keep it here instead to satisfy certain compilers. |
| 7551 #ifdef DEBUG | 7553 #ifdef OBJECT_PRINT |
| 7552 template<typename Shape, typename Key> | 7554 template<typename Shape, typename Key> |
| 7553 void Dictionary<Shape, Key>::Print() { | 7555 void Dictionary<Shape, Key>::Print(FILE* out) { |
| 7554 int capacity = HashTable<Shape, Key>::Capacity(); | 7556 int capacity = HashTable<Shape, Key>::Capacity(); |
| 7555 for (int i = 0; i < capacity; i++) { | 7557 for (int i = 0; i < capacity; i++) { |
| 7556 Object* k = HashTable<Shape, Key>::KeyAt(i); | 7558 Object* k = HashTable<Shape, Key>::KeyAt(i); |
| 7557 if (HashTable<Shape, Key>::IsKey(k)) { | 7559 if (HashTable<Shape, Key>::IsKey(k)) { |
| 7558 PrintF(" "); | 7560 PrintF(out, " "); |
| 7559 if (k->IsString()) { | 7561 if (k->IsString()) { |
| 7560 String::cast(k)->StringPrint(); | 7562 String::cast(k)->StringPrint(out); |
| 7561 } else { | 7563 } else { |
| 7562 k->ShortPrint(); | 7564 k->ShortPrint(out); |
| 7563 } | 7565 } |
| 7564 PrintF(": "); | 7566 PrintF(out, ": "); |
| 7565 ValueAt(i)->ShortPrint(); | 7567 ValueAt(i)->ShortPrint(out); |
| 7566 PrintF("\n"); | 7568 PrintF(out, "\n"); |
| 7567 } | 7569 } |
| 7568 } | 7570 } |
| 7569 } | 7571 } |
| 7570 #endif | 7572 #endif |
| 7571 | 7573 |
| 7572 | 7574 |
| 7573 template<typename Shape, typename Key> | 7575 template<typename Shape, typename Key> |
| 7574 void Dictionary<Shape, Key>::CopyValuesTo(FixedArray* elements) { | 7576 void Dictionary<Shape, Key>::CopyValuesTo(FixedArray* elements) { |
| 7575 int pos = 0; | 7577 int pos = 0; |
| 7576 int capacity = HashTable<Shape, Key>::Capacity(); | 7578 int capacity = HashTable<Shape, Key>::Capacity(); |
| (...skipping 2267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9844 if (break_point_objects()->IsUndefined()) return 0; | 9846 if (break_point_objects()->IsUndefined()) return 0; |
| 9845 // Single beak point. | 9847 // Single beak point. |
| 9846 if (!break_point_objects()->IsFixedArray()) return 1; | 9848 if (!break_point_objects()->IsFixedArray()) return 1; |
| 9847 // Multiple break points. | 9849 // Multiple break points. |
| 9848 return FixedArray::cast(break_point_objects())->length(); | 9850 return FixedArray::cast(break_point_objects())->length(); |
| 9849 } | 9851 } |
| 9850 #endif | 9852 #endif |
| 9851 | 9853 |
| 9852 | 9854 |
| 9853 } } // namespace v8::internal | 9855 } } // namespace v8::internal |
| OLD | NEW |