Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: src/objects.cc

Issue 6062002: Merge 6006:6095 from bleeding_edge to experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 if (IsNumber()) return context->number_function()->instance_prototype(); 546 if (IsNumber()) return context->number_function()->instance_prototype();
547 if (IsString()) return context->string_function()->instance_prototype(); 547 if (IsString()) return context->string_function()->instance_prototype();
548 if (IsBoolean()) { 548 if (IsBoolean()) {
549 return context->boolean_function()->instance_prototype(); 549 return context->boolean_function()->instance_prototype();
550 } else { 550 } else {
551 return Heap::null_value(); 551 return Heap::null_value();
552 } 552 }
553 } 553 }
554 554
555 555
556 void Object::ShortPrint() { 556 void Object::ShortPrint(FILE* out) {
557 HeapStringAllocator allocator; 557 HeapStringAllocator allocator;
558 StringStream accumulator(&allocator); 558 StringStream accumulator(&allocator);
559 ShortPrint(&accumulator); 559 ShortPrint(&accumulator);
560 accumulator.OutputToStdOut(); 560 accumulator.OutputToFile(out);
561 } 561 }
562 562
563 563
564 void Object::ShortPrint(StringStream* accumulator) { 564 void Object::ShortPrint(StringStream* accumulator) {
565 if (IsSmi()) { 565 if (IsSmi()) {
566 Smi::cast(this)->SmiPrint(accumulator); 566 Smi::cast(this)->SmiPrint(accumulator);
567 } else if (IsFailure()) { 567 } else if (IsFailure()) {
568 Failure::cast(this)->FailurePrint(accumulator); 568 Failure::cast(this)->FailurePrint(accumulator);
569 } else { 569 } else {
570 HeapObject::cast(this)->HeapObjectShortPrint(accumulator); 570 HeapObject::cast(this)->HeapObjectShortPrint(accumulator);
571 } 571 }
572 } 572 }
573 573
574 574
575 void Smi::SmiPrint() { 575 void Smi::SmiPrint(FILE* out) {
576 PrintF("%d", value()); 576 PrintF(out, "%d", value());
577 } 577 }
578 578
579 579
580 void Smi::SmiPrint(StringStream* accumulator) { 580 void Smi::SmiPrint(StringStream* accumulator) {
581 accumulator->Add("%d", value()); 581 accumulator->Add("%d", value());
582 } 582 }
583 583
584 584
585 void Failure::FailurePrint(StringStream* accumulator) { 585 void Failure::FailurePrint(StringStream* accumulator) {
586 accumulator->Add("Failure(%p)", reinterpret_cast<void*>(value())); 586 accumulator->Add("Failure(%p)", reinterpret_cast<void*>(value()));
587 } 587 }
588 588
589 589
590 void Failure::FailurePrint() { 590 void Failure::FailurePrint(FILE* out) {
591 PrintF("Failure(%p)", reinterpret_cast<void*>(value())); 591 PrintF(out, "Failure(%p)", reinterpret_cast<void*>(value()));
592 } 592 }
593 593
594 594
595 // Should a word be prefixed by 'a' or 'an' in order to read naturally in 595 // Should a word be prefixed by 'a' or 'an' in order to read naturally in
596 // English? Returns false for non-ASCII or words that don't start with 596 // English? Returns false for non-ASCII or words that don't start with
597 // a capital letter. The a/an rule follows pronunciation in English. 597 // a capital letter. The a/an rule follows pronunciation in English.
598 // We don't use the BBC's overcorrect "an historic occasion" though if 598 // We don't use the BBC's overcorrect "an historic occasion" though if
599 // you speak a dialect you may well say "an 'istoric occasion". 599 // you speak a dialect you may well say "an 'istoric occasion".
600 static bool AnWord(String* str) { 600 static bool AnWord(String* str) {
601 if (str->length() == 0) return false; // A nothing. 601 if (str->length() == 0) return false; // A nothing.
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 } 1134 }
1135 if (u.bits.exp == 0) { 1135 if (u.bits.exp == 0) {
1136 // Detect +0, and -0 for IEEE double precision floating point. 1136 // Detect +0, and -0 for IEEE double precision floating point.
1137 if ((u.bits.man_low | u.bits.man_high) == 0) 1137 if ((u.bits.man_low | u.bits.man_high) == 0)
1138 return Heap::false_value(); 1138 return Heap::false_value();
1139 } 1139 }
1140 return Heap::true_value(); 1140 return Heap::true_value();
1141 } 1141 }
1142 1142
1143 1143
1144 void HeapNumber::HeapNumberPrint() { 1144 void HeapNumber::HeapNumberPrint(FILE* out) {
1145 PrintF("%.16g", Number()); 1145 PrintF(out, "%.16g", Number());
1146 } 1146 }
1147 1147
1148 1148
1149 void HeapNumber::HeapNumberPrint(StringStream* accumulator) { 1149 void HeapNumber::HeapNumberPrint(StringStream* accumulator) {
1150 // The Windows version of vsnprintf can allocate when printing a %g string 1150 // The Windows version of vsnprintf can allocate when printing a %g string
1151 // into a buffer that may not be big enough. We don't want random memory 1151 // into a buffer that may not be big enough. We don't want random memory
1152 // allocation when producing post-crash stack traces, so we print into a 1152 // allocation when producing post-crash stack traces, so we print into a
1153 // buffer that is plenty big enough for any floating point number, then 1153 // buffer that is plenty big enough for any floating point number, then
1154 // print that using vsnprintf (which may truncate but never allocate if 1154 // print that using vsnprintf (which may truncate but never allocate if
1155 // there is no more space in the buffer). 1155 // there is no more space in the buffer).
(...skipping 1934 matching lines...) Expand 10 before | Expand all | Expand 10 after
3090 if (convert_back_to_fast) { 3090 if (convert_back_to_fast) {
3091 { MaybeObject* maybe_ok = TransformToFastProperties(0); 3091 { MaybeObject* maybe_ok = TransformToFastProperties(0);
3092 if (!maybe_ok->ToObject(&ok)) return maybe_ok; 3092 if (!maybe_ok->ToObject(&ok)) return maybe_ok;
3093 } 3093 }
3094 } 3094 }
3095 return result; 3095 return result;
3096 } 3096 }
3097 3097
3098 MaybeObject* JSObject::DefineAccessor(String* name, 3098 MaybeObject* JSObject::DefineAccessor(String* name,
3099 bool is_getter, 3099 bool is_getter,
3100 JSFunction* fun, 3100 Object* fun,
3101 PropertyAttributes attributes) { 3101 PropertyAttributes attributes) {
3102 ASSERT(fun->IsJSFunction() || fun->IsUndefined());
3102 // Check access rights if needed. 3103 // Check access rights if needed.
3103 if (IsAccessCheckNeeded() && 3104 if (IsAccessCheckNeeded() &&
3104 !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) { 3105 !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) {
3105 Top::ReportFailedAccessCheck(this, v8::ACCESS_SET); 3106 Top::ReportFailedAccessCheck(this, v8::ACCESS_SET);
3106 return Heap::undefined_value(); 3107 return Heap::undefined_value();
3107 } 3108 }
3108 3109
3109 if (IsJSGlobalProxy()) { 3110 if (IsJSGlobalProxy()) {
3110 Object* proto = GetPrototype(); 3111 Object* proto = GetPrototype();
3111 if (proto->IsNull()) return this; 3112 if (proto->IsNull()) return this;
(...skipping 2347 matching lines...) Expand 10 before | Expand all | Expand 10 after
5459 return this; 5460 return this;
5460 } 5461 }
5461 5462
5462 5463
5463 Object* JSFunction::SetInstanceClassName(String* name) { 5464 Object* JSFunction::SetInstanceClassName(String* name) {
5464 shared()->set_instance_class_name(name); 5465 shared()->set_instance_class_name(name);
5465 return this; 5466 return this;
5466 } 5467 }
5467 5468
5468 5469
5469 void JSFunction::PrintName() { 5470 void JSFunction::PrintName(FILE* out) {
5470 SmartPointer<char> name = shared()->DebugName()->ToCString(); 5471 SmartPointer<char> name = shared()->DebugName()->ToCString();
5471 PrintF("%s", *name); 5472 PrintF(out, "%s", *name);
5472 } 5473 }
5473 5474
5474 5475
5475 Context* JSFunction::GlobalContextFromLiterals(FixedArray* literals) { 5476 Context* JSFunction::GlobalContextFromLiterals(FixedArray* literals) {
5476 return Context::cast(literals->get(JSFunction::kLiteralGlobalContextIndex)); 5477 return Context::cast(literals->get(JSFunction::kLiteralGlobalContextIndex));
5477 } 5478 }
5478 5479
5479 5480
5480 MaybeObject* Oddball::Initialize(const char* to_string, Object* to_number) { 5481 MaybeObject* Oddball::Initialize(const char* to_string, Object* to_number) {
5481 Object* symbol; 5482 Object* symbol;
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
5991 RelocInfo* info = it.rinfo(); 5992 RelocInfo* info = it.rinfo();
5992 Object* object = info->target_object(); 5993 Object* object = info->target_object();
5993 if (object->IsMap()) return Map::cast(object); 5994 if (object->IsMap()) return Map::cast(object);
5994 } 5995 }
5995 return NULL; 5996 return NULL;
5996 } 5997 }
5997 5998
5998 5999
5999 #ifdef ENABLE_DISASSEMBLER 6000 #ifdef ENABLE_DISASSEMBLER
6000 6001
6001 #ifdef DEBUG 6002 #ifdef OBJECT_PRINT
6002 6003
6003 void DeoptimizationInputData::DeoptimizationInputDataPrint() { 6004 void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) {
6004 disasm::NameConverter converter; 6005 disasm::NameConverter converter;
6005 int deopt_count = DeoptCount(); 6006 int deopt_count = DeoptCount();
6006 PrintF("Deoptimization Input Data (deopt points = %d)\n", deopt_count); 6007 PrintF(out, "Deoptimization Input Data (deopt points = %d)\n", deopt_count);
6007 if (0 == deopt_count) return; 6008 if (0 == deopt_count) return;
6008 6009
6009 PrintF("%6s %6s %6s %12s\n", "index", "ast id", "argc", "commands"); 6010 PrintF(out, "%6s %6s %6s %12s\n", "index", "ast id", "argc", "commands");
6010 for (int i = 0; i < deopt_count; i++) { 6011 for (int i = 0; i < deopt_count; i++) {
6011 int command_count = 0; 6012 int command_count = 0;
6012 PrintF("%6d %6d %6d", 6013 PrintF(out, "%6d %6d %6d",
6013 i, AstId(i)->value(), ArgumentsStackHeight(i)->value()); 6014 i, AstId(i)->value(), ArgumentsStackHeight(i)->value());
6014 int translation_index = TranslationIndex(i)->value(); 6015 int translation_index = TranslationIndex(i)->value();
6015 TranslationIterator iterator(TranslationByteArray(), translation_index); 6016 TranslationIterator iterator(TranslationByteArray(), translation_index);
6016 Translation::Opcode opcode = 6017 Translation::Opcode opcode =
6017 static_cast<Translation::Opcode>(iterator.Next()); 6018 static_cast<Translation::Opcode>(iterator.Next());
6018 ASSERT(Translation::BEGIN == opcode); 6019 ASSERT(Translation::BEGIN == opcode);
6019 int frame_count = iterator.Next(); 6020 int frame_count = iterator.Next();
6020 if (FLAG_print_code_verbose) { 6021 if (FLAG_print_code_verbose) {
6021 PrintF(" %s {count=%d}\n", Translation::StringFor(opcode), frame_count); 6022 PrintF(out, " %s {count=%d}\n", Translation::StringFor(opcode),
6023 frame_count);
6022 } 6024 }
6023 6025
6024 for (int i = 0; i < frame_count; ++i) { 6026 for (int i = 0; i < frame_count; ++i) {
6025 opcode = static_cast<Translation::Opcode>(iterator.Next()); 6027 opcode = static_cast<Translation::Opcode>(iterator.Next());
6026 ASSERT(Translation::FRAME == opcode); 6028 ASSERT(Translation::FRAME == opcode);
6027 int ast_id = iterator.Next(); 6029 int ast_id = iterator.Next();
6028 int function_id = iterator.Next(); 6030 int function_id = iterator.Next();
6029 JSFunction* function = 6031 JSFunction* function =
6030 JSFunction::cast(LiteralArray()->get(function_id)); 6032 JSFunction::cast(LiteralArray()->get(function_id));
6031 unsigned height = iterator.Next(); 6033 unsigned height = iterator.Next();
6032 if (FLAG_print_code_verbose) { 6034 if (FLAG_print_code_verbose) {
6033 PrintF("%24s %s {ast_id=%d, function=", 6035 PrintF(out, "%24s %s {ast_id=%d, function=",
6034 "", Translation::StringFor(opcode), ast_id); 6036 "", Translation::StringFor(opcode), ast_id);
6035 function->PrintName(); 6037 function->PrintName(out);
6036 PrintF(", height=%u}\n", height); 6038 PrintF(out, ", height=%u}\n", height);
6037 } 6039 }
6038 6040
6039 // Size of translation is height plus all incoming arguments including 6041 // Size of translation is height plus all incoming arguments including
6040 // receiver. 6042 // receiver.
6041 int size = height + function->shared()->formal_parameter_count() + 1; 6043 int size = height + function->shared()->formal_parameter_count() + 1;
6042 command_count += size; 6044 command_count += size;
6043 for (int j = 0; j < size; ++j) { 6045 for (int j = 0; j < size; ++j) {
6044 opcode = static_cast<Translation::Opcode>(iterator.Next()); 6046 opcode = static_cast<Translation::Opcode>(iterator.Next());
6045 if (FLAG_print_code_verbose) { 6047 if (FLAG_print_code_verbose) {
6046 PrintF("%24s %s ", "", Translation::StringFor(opcode)); 6048 PrintF(out, "%24s %s ", "", Translation::StringFor(opcode));
6047 } 6049 }
6048 6050
6049 if (opcode == Translation::DUPLICATE) { 6051 if (opcode == Translation::DUPLICATE) {
6050 opcode = static_cast<Translation::Opcode>(iterator.Next()); 6052 opcode = static_cast<Translation::Opcode>(iterator.Next());
6051 if (FLAG_print_code_verbose) { 6053 if (FLAG_print_code_verbose) {
6052 PrintF("%s ", Translation::StringFor(opcode)); 6054 PrintF(out, "%s ", Translation::StringFor(opcode));
6053 } 6055 }
6054 --j; // Two commands share the same frame index. 6056 --j; // Two commands share the same frame index.
6055 } 6057 }
6056 6058
6057 switch (opcode) { 6059 switch (opcode) {
6058 case Translation::BEGIN: 6060 case Translation::BEGIN:
6059 case Translation::FRAME: 6061 case Translation::FRAME:
6060 case Translation::DUPLICATE: 6062 case Translation::DUPLICATE:
6061 UNREACHABLE(); 6063 UNREACHABLE();
6062 break; 6064 break;
6063 6065
6064 case Translation::REGISTER: { 6066 case Translation::REGISTER: {
6065 int reg_code = iterator.Next(); 6067 int reg_code = iterator.Next();
6066 if (FLAG_print_code_verbose) { 6068 if (FLAG_print_code_verbose) {
6067 PrintF("{input=%s}", converter.NameOfCPURegister(reg_code)); 6069 PrintF(out, "{input=%s}", converter.NameOfCPURegister(reg_code));
6068 } 6070 }
6069 break; 6071 break;
6070 } 6072 }
6071 6073
6072 case Translation::INT32_REGISTER: { 6074 case Translation::INT32_REGISTER: {
6073 int reg_code = iterator.Next(); 6075 int reg_code = iterator.Next();
6074 if (FLAG_print_code_verbose) { 6076 if (FLAG_print_code_verbose) {
6075 PrintF("{input=%s}", converter.NameOfCPURegister(reg_code)); 6077 PrintF(out, "{input=%s}", converter.NameOfCPURegister(reg_code));
6076 } 6078 }
6077 break; 6079 break;
6078 } 6080 }
6079 6081
6080 case Translation::DOUBLE_REGISTER: { 6082 case Translation::DOUBLE_REGISTER: {
6081 int reg_code = iterator.Next(); 6083 int reg_code = iterator.Next();
6082 if (FLAG_print_code_verbose) { 6084 if (FLAG_print_code_verbose) {
6083 PrintF("{input=%s}", 6085 PrintF(out, "{input=%s}",
6084 DoubleRegister::AllocationIndexToString(reg_code)); 6086 DoubleRegister::AllocationIndexToString(reg_code));
6085 } 6087 }
6086 break; 6088 break;
6087 } 6089 }
6088 6090
6089 case Translation::STACK_SLOT: { 6091 case Translation::STACK_SLOT: {
6090 int input_slot_index = iterator.Next(); 6092 int input_slot_index = iterator.Next();
6091 if (FLAG_print_code_verbose) { 6093 if (FLAG_print_code_verbose) {
6092 PrintF("{input=%d}", input_slot_index); 6094 PrintF(out, "{input=%d}", input_slot_index);
6093 } 6095 }
6094 break; 6096 break;
6095 } 6097 }
6096 6098
6097 case Translation::INT32_STACK_SLOT: { 6099 case Translation::INT32_STACK_SLOT: {
6098 int input_slot_index = iterator.Next(); 6100 int input_slot_index = iterator.Next();
6099 if (FLAG_print_code_verbose) { 6101 if (FLAG_print_code_verbose) {
6100 PrintF("{input=%d}", input_slot_index); 6102 PrintF(out, "{input=%d}", input_slot_index);
6101 } 6103 }
6102 break; 6104 break;
6103 } 6105 }
6104 6106
6105 case Translation::DOUBLE_STACK_SLOT: { 6107 case Translation::DOUBLE_STACK_SLOT: {
6106 int input_slot_index = iterator.Next(); 6108 int input_slot_index = iterator.Next();
6107 if (FLAG_print_code_verbose) { 6109 if (FLAG_print_code_verbose) {
6108 PrintF("{input=%d}", input_slot_index); 6110 PrintF(out, "{input=%d}", input_slot_index);
6109 } 6111 }
6110 break; 6112 break;
6111 } 6113 }
6112 6114
6113 case Translation::LITERAL: { 6115 case Translation::LITERAL: {
6114 unsigned literal_index = iterator.Next(); 6116 unsigned literal_index = iterator.Next();
6115 if (FLAG_print_code_verbose) { 6117 if (FLAG_print_code_verbose) {
6116 PrintF("{literal_id=%u}", literal_index); 6118 PrintF(out, "{literal_id=%u}", literal_index);
6117 } 6119 }
6118 break; 6120 break;
6119 } 6121 }
6120 6122
6121 case Translation::ARGUMENTS_OBJECT: 6123 case Translation::ARGUMENTS_OBJECT:
6122 break; 6124 break;
6123 } 6125 }
6124 if (FLAG_print_code_verbose) PrintF("\n"); 6126 if (FLAG_print_code_verbose) PrintF(out, "\n");
6125 } 6127 }
6126 } 6128 }
6127 if (!FLAG_print_code_verbose) PrintF(" %12d\n", command_count); 6129 if (!FLAG_print_code_verbose) PrintF(out, " %12d\n", command_count);
6128 } 6130 }
6129 } 6131 }
6130 6132
6131 6133
6132 void DeoptimizationOutputData::DeoptimizationOutputDataPrint() { 6134 void DeoptimizationOutputData::DeoptimizationOutputDataPrint(FILE* out) {
6133 PrintF("Deoptimization Output Data (deopt points = %d)\n", 6135 PrintF(out, "Deoptimization Output Data (deopt points = %d)\n",
6134 this->DeoptPoints()); 6136 this->DeoptPoints());
6135 if (this->DeoptPoints() == 0) return; 6137 if (this->DeoptPoints() == 0) return;
6136 6138
6137 PrintF("%6s %8s %s\n", "ast id", "pc", "state"); 6139 PrintF("%6s %8s %s\n", "ast id", "pc", "state");
6138 for (int i = 0; i < this->DeoptPoints(); i++) { 6140 for (int i = 0; i < this->DeoptPoints(); i++) {
6139 int pc_and_state = this->PcAndState(i)->value(); 6141 int pc_and_state = this->PcAndState(i)->value();
6140 PrintF("%6d %8d %s\n", 6142 PrintF("%6d %8d %s\n",
6141 this->AstId(i)->value(), 6143 this->AstId(i)->value(),
6142 FullCodeGenerator::PcField::decode(pc_and_state), 6144 FullCodeGenerator::PcField::decode(pc_and_state),
6143 FullCodeGenerator::State2String( 6145 FullCodeGenerator::State2String(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
6194 case INTERCEPTOR: return "INTERCEPTOR"; 6196 case INTERCEPTOR: return "INTERCEPTOR";
6195 case MAP_TRANSITION: return "MAP_TRANSITION"; 6197 case MAP_TRANSITION: return "MAP_TRANSITION";
6196 case CONSTANT_TRANSITION: return "CONSTANT_TRANSITION"; 6198 case CONSTANT_TRANSITION: return "CONSTANT_TRANSITION";
6197 case NULL_DESCRIPTOR: return "NULL_DESCRIPTOR"; 6199 case NULL_DESCRIPTOR: return "NULL_DESCRIPTOR";
6198 } 6200 }
6199 UNREACHABLE(); 6201 UNREACHABLE();
6200 return NULL; 6202 return NULL;
6201 } 6203 }
6202 6204
6203 6205
6204 void Code::Disassemble(const char* name) { 6206 void Code::Disassemble(const char* name, FILE* out) {
6205 PrintF("kind = %s\n", Kind2String(kind())); 6207 PrintF(out, "kind = %s\n", Kind2String(kind()));
6206 if (is_inline_cache_stub()) { 6208 if (is_inline_cache_stub()) {
6207 PrintF("ic_state = %s\n", ICState2String(ic_state())); 6209 PrintF(out, "ic_state = %s\n", ICState2String(ic_state()));
6208 PrintF("ic_in_loop = %d\n", ic_in_loop() == IN_LOOP); 6210 PrintF(out, "ic_in_loop = %d\n", ic_in_loop() == IN_LOOP);
6209 if (ic_state() == MONOMORPHIC) { 6211 if (ic_state() == MONOMORPHIC) {
6210 PrintF("type = %s\n", PropertyType2String(type())); 6212 PrintF(out, "type = %s\n", PropertyType2String(type()));
6211 } 6213 }
6212 } 6214 }
6213 if ((name != NULL) && (name[0] != '\0')) { 6215 if ((name != NULL) && (name[0] != '\0')) {
6214 PrintF("name = %s\n", name); 6216 PrintF(out, "name = %s\n", name);
6215 } 6217 }
6216 if (kind() == OPTIMIZED_FUNCTION) { 6218 if (kind() == OPTIMIZED_FUNCTION) {
6217 PrintF("stack_slots = %d\n", stack_slots()); 6219 PrintF(out, "stack_slots = %d\n", stack_slots());
6218 } 6220 }
6219 6221
6220 PrintF("Instructions (size = %d)\n", instruction_size()); 6222 PrintF(out, "Instructions (size = %d)\n", instruction_size());
6221 Disassembler::Decode(NULL, this); 6223 Disassembler::Decode(out, this);
6222 PrintF("\n"); 6224 PrintF(out, "\n");
6223 6225
6224 #ifdef DEBUG 6226 #ifdef DEBUG
6225 if (kind() == FUNCTION) { 6227 if (kind() == FUNCTION) {
6226 DeoptimizationOutputData* data = 6228 DeoptimizationOutputData* data =
6227 DeoptimizationOutputData::cast(this->deoptimization_data()); 6229 DeoptimizationOutputData::cast(this->deoptimization_data());
6228 data->DeoptimizationOutputDataPrint(); 6230 data->DeoptimizationOutputDataPrint(out);
6229 } else if (kind() == OPTIMIZED_FUNCTION) { 6231 } else if (kind() == OPTIMIZED_FUNCTION) {
6230 DeoptimizationInputData* data = 6232 DeoptimizationInputData* data =
6231 DeoptimizationInputData::cast(this->deoptimization_data()); 6233 DeoptimizationInputData::cast(this->deoptimization_data());
6232 data->DeoptimizationInputDataPrint(); 6234 data->DeoptimizationInputDataPrint(out);
6233 } 6235 }
6234 PrintF("\n"); 6236 PrintF("\n");
6235 #endif 6237 #endif
6236 6238
6237 if (kind() == OPTIMIZED_FUNCTION) { 6239 if (kind() == OPTIMIZED_FUNCTION) {
6238 SafepointTable table(this); 6240 SafepointTable table(this);
6239 PrintF("Safepoints (size = %u)\n", table.size()); 6241 PrintF(out, "Safepoints (size = %u)\n", table.size());
6240 for (unsigned i = 0; i < table.length(); i++) { 6242 for (unsigned i = 0; i < table.length(); i++) {
6241 unsigned pc_offset = table.GetPcOffset(i); 6243 unsigned pc_offset = table.GetPcOffset(i);
6242 PrintF("%p %4d ", (instruction_start() + pc_offset), pc_offset); 6244 PrintF(out, "%p %4d ", (instruction_start() + pc_offset), pc_offset);
6243 table.PrintEntry(i); 6245 table.PrintEntry(i);
6244 PrintF(" (sp -> fp)"); 6246 PrintF(out, " (sp -> fp)");
6245 int deoptimization_index = table.GetDeoptimizationIndex(i); 6247 int deoptimization_index = table.GetDeoptimizationIndex(i);
6246 if (deoptimization_index != Safepoint::kNoDeoptimizationIndex) { 6248 if (deoptimization_index != Safepoint::kNoDeoptimizationIndex) {
6247 PrintF(" %6d", deoptimization_index); 6249 PrintF(out, " %6d", deoptimization_index);
6248 } else { 6250 } else {
6249 PrintF(" <none>"); 6251 PrintF(out, " <none>");
6250 } 6252 }
6251 PrintF("\n"); 6253 PrintF(out, "\n");
6252 } 6254 }
6253 PrintF("\n"); 6255 PrintF(out, "\n");
6254 } else if (kind() == FUNCTION) { 6256 } else if (kind() == FUNCTION) {
6255 unsigned offset = stack_check_table_start(); 6257 unsigned offset = stack_check_table_start();
6256 // If there is no stack check table, the "table start" will at or after 6258 // If there is no stack check table, the "table start" will at or after
6257 // (due to alignment) the end of the instruction stream. 6259 // (due to alignment) the end of the instruction stream.
6258 if (static_cast<int>(offset) < instruction_size()) { 6260 if (static_cast<int>(offset) < instruction_size()) {
6259 unsigned* address = 6261 unsigned* address =
6260 reinterpret_cast<unsigned*>(instruction_start() + offset); 6262 reinterpret_cast<unsigned*>(instruction_start() + offset);
6261 unsigned length = address[0]; 6263 unsigned length = address[0];
6262 PrintF("Stack checks (size = %u)\n", length); 6264 PrintF(out, "Stack checks (size = %u)\n", length);
6263 PrintF("ast_id pc_offset\n"); 6265 PrintF(out, "ast_id pc_offset\n");
6264 for (unsigned i = 0; i < length; ++i) { 6266 for (unsigned i = 0; i < length; ++i) {
6265 unsigned index = (2 * i) + 1; 6267 unsigned index = (2 * i) + 1;
6266 PrintF("%6u %9u\n", address[index], address[index + 1]); 6268 PrintF(out, "%6u %9u\n", address[index], address[index + 1]);
6267 } 6269 }
6268 PrintF("\n"); 6270 PrintF(out, "\n");
6269 } 6271 }
6270 } 6272 }
6271 6273
6272 PrintF("RelocInfo (size = %d)\n", relocation_size()); 6274 PrintF("RelocInfo (size = %d)\n", relocation_size());
6273 for (RelocIterator it(this); !it.done(); it.next()) it.rinfo()->Print(); 6275 for (RelocIterator it(this); !it.done(); it.next()) it.rinfo()->Print(out);
6274 PrintF("\n"); 6276 PrintF(out, "\n");
6275 } 6277 }
6276 #endif // ENABLE_DISASSEMBLER 6278 #endif // ENABLE_DISASSEMBLER
6277 6279
6278 6280
6279 MaybeObject* JSObject::SetFastElementsCapacityAndLength(int capacity, 6281 MaybeObject* JSObject::SetFastElementsCapacityAndLength(int capacity,
6280 int length) { 6282 int length) {
6281 // We should never end in here with a pixel or external array. 6283 // We should never end in here with a pixel or external array.
6282 ASSERT(!HasPixelElements() && !HasExternalArrayElements()); 6284 ASSERT(!HasPixelElements() && !HasExternalArrayElements());
6283 6285
6284 Object* obj; 6286 Object* obj;
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after
7413 return static_cast<uint32_t>(dictionary->Capacity()) >= 7415 return static_cast<uint32_t>(dictionary->Capacity()) >=
7414 (length / (2 * NumberDictionary::kEntrySize)); 7416 (length / (2 * NumberDictionary::kEntrySize));
7415 } 7417 }
7416 7418
7417 7419
7418 // Certain compilers request function template instantiation when they 7420 // Certain compilers request function template instantiation when they
7419 // see the definition of the other template functions in the 7421 // see the definition of the other template functions in the
7420 // class. This requires us to have the template functions put 7422 // class. This requires us to have the template functions put
7421 // together, so even though this function belongs in objects-debug.cc, 7423 // together, so even though this function belongs in objects-debug.cc,
7422 // we keep it here instead to satisfy certain compilers. 7424 // we keep it here instead to satisfy certain compilers.
7423 #ifdef DEBUG 7425 #ifdef OBJECT_PRINT
7424 template<typename Shape, typename Key> 7426 template<typename Shape, typename Key>
7425 void Dictionary<Shape, Key>::Print() { 7427 void Dictionary<Shape, Key>::Print(FILE* out) {
7426 int capacity = HashTable<Shape, Key>::Capacity(); 7428 int capacity = HashTable<Shape, Key>::Capacity();
7427 for (int i = 0; i < capacity; i++) { 7429 for (int i = 0; i < capacity; i++) {
7428 Object* k = HashTable<Shape, Key>::KeyAt(i); 7430 Object* k = HashTable<Shape, Key>::KeyAt(i);
7429 if (HashTable<Shape, Key>::IsKey(k)) { 7431 if (HashTable<Shape, Key>::IsKey(k)) {
7430 PrintF(" "); 7432 PrintF(out, " ");
7431 if (k->IsString()) { 7433 if (k->IsString()) {
7432 String::cast(k)->StringPrint(); 7434 String::cast(k)->StringPrint(out);
7433 } else { 7435 } else {
7434 k->ShortPrint(); 7436 k->ShortPrint(out);
7435 } 7437 }
7436 PrintF(": "); 7438 PrintF(out, ": ");
7437 ValueAt(i)->ShortPrint(); 7439 ValueAt(i)->ShortPrint(out);
7438 PrintF("\n"); 7440 PrintF(out, "\n");
7439 } 7441 }
7440 } 7442 }
7441 } 7443 }
7442 #endif 7444 #endif
7443 7445
7444 7446
7445 template<typename Shape, typename Key> 7447 template<typename Shape, typename Key>
7446 void Dictionary<Shape, Key>::CopyValuesTo(FixedArray* elements) { 7448 void Dictionary<Shape, Key>::CopyValuesTo(FixedArray* elements) {
7447 int pos = 0; 7449 int pos = 0;
7448 int capacity = HashTable<Shape, Key>::Capacity(); 7450 int capacity = HashTable<Shape, Key>::Capacity();
(...skipping 2296 matching lines...) Expand 10 before | Expand all | Expand 10 after
9745 if (break_point_objects()->IsUndefined()) return 0; 9747 if (break_point_objects()->IsUndefined()) return 0;
9746 // Single beak point. 9748 // Single beak point.
9747 if (!break_point_objects()->IsFixedArray()) return 1; 9749 if (!break_point_objects()->IsFixedArray()) return 1;
9748 // Multiple break points. 9750 // Multiple break points.
9749 return FixedArray::cast(break_point_objects())->length(); 9751 return FixedArray::cast(break_point_objects())->length();
9750 } 9752 }
9751 #endif 9753 #endif
9752 9754
9753 9755
9754 } } // namespace v8::internal 9756 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698