| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 8321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8332 } | 8332 } |
| 8333 | 8333 |
| 8334 | 8334 |
| 8335 SmartArrayPointer<char> String::ToCString(AllowNullsFlag allow_nulls, | 8335 SmartArrayPointer<char> String::ToCString(AllowNullsFlag allow_nulls, |
| 8336 RobustnessFlag robust_flag, | 8336 RobustnessFlag robust_flag, |
| 8337 int* length_return) { | 8337 int* length_return) { |
| 8338 return ToCString(allow_nulls, robust_flag, 0, -1, length_return); | 8338 return ToCString(allow_nulls, robust_flag, 0, -1, length_return); |
| 8339 } | 8339 } |
| 8340 | 8340 |
| 8341 | 8341 |
| 8342 const uc16* String::GetTwoByteData() { | |
| 8343 return GetTwoByteData(0); | |
| 8344 } | |
| 8345 | |
| 8346 | |
| 8347 const uc16* String::GetTwoByteData(unsigned start) { | 8342 const uc16* String::GetTwoByteData(unsigned start) { |
| 8348 ASSERT(!IsOneByteRepresentationUnderneath()); | 8343 ASSERT(!IsOneByteRepresentationUnderneath()); |
| 8349 switch (StringShape(this).representation_tag()) { | 8344 switch (StringShape(this).representation_tag()) { |
| 8350 case kSeqStringTag: | 8345 case kSeqStringTag: |
| 8351 return SeqTwoByteString::cast(this)->SeqTwoByteStringGetData(start); | 8346 return SeqTwoByteString::cast(this)->SeqTwoByteStringGetData(start); |
| 8352 case kExternalStringTag: | 8347 case kExternalStringTag: |
| 8353 return ExternalTwoByteString::cast(this)-> | 8348 return ExternalTwoByteString::cast(this)-> |
| 8354 ExternalTwoByteStringGetData(start); | 8349 ExternalTwoByteStringGetData(start); |
| 8355 case kSlicedStringTag: { | 8350 case kSlicedStringTag: { |
| 8356 SlicedString* slice = SlicedString::cast(this); | 8351 SlicedString* slice = SlicedString::cast(this); |
| (...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9581 FixedArray* literals) { | 9576 FixedArray* literals) { |
| 9582 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); | 9577 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); |
| 9583 ASSERT(native_context->IsNativeContext()); | 9578 ASSERT(native_context->IsNativeContext()); |
| 9584 STATIC_ASSERT(kEntryLength == 3); | 9579 STATIC_ASSERT(kEntryLength == 3); |
| 9585 Heap* heap = GetHeap(); | 9580 Heap* heap = GetHeap(); |
| 9586 FixedArray* new_code_map; | 9581 FixedArray* new_code_map; |
| 9587 Object* value = optimized_code_map(); | 9582 Object* value = optimized_code_map(); |
| 9588 if (value->IsSmi()) { | 9583 if (value->IsSmi()) { |
| 9589 // No optimized code map. | 9584 // No optimized code map. |
| 9590 ASSERT_EQ(0, Smi::cast(value)->value()); | 9585 ASSERT_EQ(0, Smi::cast(value)->value()); |
| 9591 // Crate 3 entries per context {context, code, literals}. | 9586 // Create 3 entries per context {context, code, literals}. |
| 9592 MaybeObject* maybe = heap->AllocateFixedArray(kInitialLength); | 9587 MaybeObject* maybe = heap->AllocateFixedArray(kInitialLength); |
| 9593 if (!maybe->To(&new_code_map)) return maybe; | 9588 if (!maybe->To(&new_code_map)) return maybe; |
| 9594 new_code_map->set(kEntriesStart + 0, native_context); | 9589 new_code_map->set(kEntriesStart + 0, native_context); |
| 9595 new_code_map->set(kEntriesStart + 1, code); | 9590 new_code_map->set(kEntriesStart + 1, code); |
| 9596 new_code_map->set(kEntriesStart + 2, literals); | 9591 new_code_map->set(kEntriesStart + 2, literals); |
| 9597 } else { | 9592 } else { |
| 9598 // Copy old map and append one new entry. | 9593 // Copy old map and append one new entry. |
| 9599 FixedArray* old_code_map = FixedArray::cast(value); | 9594 FixedArray* old_code_map = FixedArray::cast(value); |
| 9600 ASSERT_EQ(-1, SearchOptimizedCodeMap(native_context)); | 9595 ASSERT_EQ(-1, SearchOptimizedCodeMap(native_context)); |
| 9601 int old_length = old_code_map->length(); | 9596 int old_length = old_code_map->length(); |
| (...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10536 | 10531 |
| 10537 Map* Code::FindFirstMap() { | 10532 Map* Code::FindFirstMap() { |
| 10538 Object* result = FindNthObject(1, GetHeap()->meta_map()); | 10533 Object* result = FindNthObject(1, GetHeap()->meta_map()); |
| 10539 return (result != NULL) ? Map::cast(result) : NULL; | 10534 return (result != NULL) ? Map::cast(result) : NULL; |
| 10540 } | 10535 } |
| 10541 | 10536 |
| 10542 | 10537 |
| 10543 void Code::ReplaceNthObject(int n, | 10538 void Code::ReplaceNthObject(int n, |
| 10544 Map* match_map, | 10539 Map* match_map, |
| 10545 Object* replace_with) { | 10540 Object* replace_with) { |
| 10546 ASSERT(is_inline_cache_stub()); | 10541 ASSERT(is_inline_cache_stub() || is_handler()); |
| 10547 DisallowHeapAllocation no_allocation; | 10542 DisallowHeapAllocation no_allocation; |
| 10548 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | 10543 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); |
| 10549 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10544 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
| 10550 RelocInfo* info = it.rinfo(); | 10545 RelocInfo* info = it.rinfo(); |
| 10551 Object* object = info->target_object(); | 10546 Object* object = info->target_object(); |
| 10552 if (object->IsHeapObject()) { | 10547 if (object->IsHeapObject()) { |
| 10553 if (HeapObject::cast(object)->map() == match_map) { | 10548 if (HeapObject::cast(object)->map() == match_map) { |
| 10554 if (--n == 0) { | 10549 if (--n == 0) { |
| 10555 info->set_target_object(replace_with); | 10550 info->set_target_object(replace_with); |
| 10556 return; | 10551 return; |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10824 return *builtins->MarkCodeAsExecutedTwice(); | 10819 return *builtins->MarkCodeAsExecutedTwice(); |
| 10825 } | 10820 } |
| 10826 default: | 10821 default: |
| 10827 UNREACHABLE(); | 10822 UNREACHABLE(); |
| 10828 break; | 10823 break; |
| 10829 } | 10824 } |
| 10830 return NULL; | 10825 return NULL; |
| 10831 } | 10826 } |
| 10832 | 10827 |
| 10833 | 10828 |
| 10834 void Code::PrintDeoptLocation(int bailout_id) { | 10829 void Code::PrintDeoptLocation(FILE* out, int bailout_id) { |
| 10835 const char* last_comment = NULL; | 10830 const char* last_comment = NULL; |
| 10836 int mask = RelocInfo::ModeMask(RelocInfo::COMMENT) | 10831 int mask = RelocInfo::ModeMask(RelocInfo::COMMENT) |
| 10837 | RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); | 10832 | RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); |
| 10838 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10833 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
| 10839 RelocInfo* info = it.rinfo(); | 10834 RelocInfo* info = it.rinfo(); |
| 10840 if (info->rmode() == RelocInfo::COMMENT) { | 10835 if (info->rmode() == RelocInfo::COMMENT) { |
| 10841 last_comment = reinterpret_cast<const char*>(info->data()); | 10836 last_comment = reinterpret_cast<const char*>(info->data()); |
| 10842 } else if (last_comment != NULL) { | 10837 } else if (last_comment != NULL) { |
| 10843 if ((bailout_id == Deoptimizer::GetDeoptimizationId( | 10838 if ((bailout_id == Deoptimizer::GetDeoptimizationId( |
| 10844 GetIsolate(), info->target_address(), Deoptimizer::EAGER)) || | 10839 GetIsolate(), info->target_address(), Deoptimizer::EAGER)) || |
| 10845 (bailout_id == Deoptimizer::GetDeoptimizationId( | 10840 (bailout_id == Deoptimizer::GetDeoptimizationId( |
| 10846 GetIsolate(), info->target_address(), Deoptimizer::SOFT))) { | 10841 GetIsolate(), info->target_address(), Deoptimizer::SOFT))) { |
| 10847 CHECK(RelocInfo::IsRuntimeEntry(info->rmode())); | 10842 CHECK(RelocInfo::IsRuntimeEntry(info->rmode())); |
| 10848 PrintF(" %s\n", last_comment); | 10843 PrintF(out, " %s\n", last_comment); |
| 10849 return; | 10844 return; |
| 10850 } | 10845 } |
| 10851 } | 10846 } |
| 10852 } | 10847 } |
| 10853 } | 10848 } |
| 10854 | 10849 |
| 10855 | 10850 |
| 10856 bool Code::CanDeoptAt(Address pc) { | 10851 bool Code::CanDeoptAt(Address pc) { |
| 10857 DeoptimizationInputData* deopt_data = | 10852 DeoptimizationInputData* deopt_data = |
| 10858 DeoptimizationInputData::cast(deoptimization_data()); | 10853 DeoptimizationInputData::cast(deoptimization_data()); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11040 } | 11035 } |
| 11041 } | 11036 } |
| 11042 } | 11037 } |
| 11043 | 11038 |
| 11044 | 11039 |
| 11045 void DeoptimizationOutputData::DeoptimizationOutputDataPrint(FILE* out) { | 11040 void DeoptimizationOutputData::DeoptimizationOutputDataPrint(FILE* out) { |
| 11046 PrintF(out, "Deoptimization Output Data (deopt points = %d)\n", | 11041 PrintF(out, "Deoptimization Output Data (deopt points = %d)\n", |
| 11047 this->DeoptPoints()); | 11042 this->DeoptPoints()); |
| 11048 if (this->DeoptPoints() == 0) return; | 11043 if (this->DeoptPoints() == 0) return; |
| 11049 | 11044 |
| 11050 PrintF("%6s %8s %s\n", "ast id", "pc", "state"); | 11045 PrintF(out, "%6s %8s %s\n", "ast id", "pc", "state"); |
| 11051 for (int i = 0; i < this->DeoptPoints(); i++) { | 11046 for (int i = 0; i < this->DeoptPoints(); i++) { |
| 11052 int pc_and_state = this->PcAndState(i)->value(); | 11047 int pc_and_state = this->PcAndState(i)->value(); |
| 11053 PrintF("%6d %8d %s\n", | 11048 PrintF(out, "%6d %8d %s\n", |
| 11054 this->AstId(i).ToInt(), | 11049 this->AstId(i).ToInt(), |
| 11055 FullCodeGenerator::PcField::decode(pc_and_state), | 11050 FullCodeGenerator::PcField::decode(pc_and_state), |
| 11056 FullCodeGenerator::State2String( | 11051 FullCodeGenerator::State2String( |
| 11057 FullCodeGenerator::StateField::decode(pc_and_state))); | 11052 FullCodeGenerator::StateField::decode(pc_and_state))); |
| 11058 } | 11053 } |
| 11059 } | 11054 } |
| 11060 | 11055 |
| 11061 | 11056 |
| 11062 const char* Code::ICState2String(InlineCacheState state) { | 11057 const char* Code::ICState2String(InlineCacheState state) { |
| 11063 switch (state) { | 11058 switch (state) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11154 | 11149 |
| 11155 if (kind() == FUNCTION) { | 11150 if (kind() == FUNCTION) { |
| 11156 DeoptimizationOutputData* data = | 11151 DeoptimizationOutputData* data = |
| 11157 DeoptimizationOutputData::cast(this->deoptimization_data()); | 11152 DeoptimizationOutputData::cast(this->deoptimization_data()); |
| 11158 data->DeoptimizationOutputDataPrint(out); | 11153 data->DeoptimizationOutputDataPrint(out); |
| 11159 } else if (kind() == OPTIMIZED_FUNCTION) { | 11154 } else if (kind() == OPTIMIZED_FUNCTION) { |
| 11160 DeoptimizationInputData* data = | 11155 DeoptimizationInputData* data = |
| 11161 DeoptimizationInputData::cast(this->deoptimization_data()); | 11156 DeoptimizationInputData::cast(this->deoptimization_data()); |
| 11162 data->DeoptimizationInputDataPrint(out); | 11157 data->DeoptimizationInputDataPrint(out); |
| 11163 } | 11158 } |
| 11164 PrintF("\n"); | 11159 PrintF(out, "\n"); |
| 11165 | 11160 |
| 11166 if (is_crankshafted()) { | 11161 if (is_crankshafted()) { |
| 11167 SafepointTable table(this); | 11162 SafepointTable table(this); |
| 11168 PrintF(out, "Safepoints (size = %u)\n", table.size()); | 11163 PrintF(out, "Safepoints (size = %u)\n", table.size()); |
| 11169 for (unsigned i = 0; i < table.length(); i++) { | 11164 for (unsigned i = 0; i < table.length(); i++) { |
| 11170 unsigned pc_offset = table.GetPcOffset(i); | 11165 unsigned pc_offset = table.GetPcOffset(i); |
| 11171 PrintF(out, "%p %4d ", (instruction_start() + pc_offset), pc_offset); | 11166 PrintF(out, "%p %4d ", (instruction_start() + pc_offset), pc_offset); |
| 11172 table.PrintEntry(i); | 11167 table.PrintEntry(i, out); |
| 11173 PrintF(out, " (sp -> fp)"); | 11168 PrintF(out, " (sp -> fp)"); |
| 11174 SafepointEntry entry = table.GetEntry(i); | 11169 SafepointEntry entry = table.GetEntry(i); |
| 11175 if (entry.deoptimization_index() != Safepoint::kNoDeoptimizationIndex) { | 11170 if (entry.deoptimization_index() != Safepoint::kNoDeoptimizationIndex) { |
| 11176 PrintF(out, " %6d", entry.deoptimization_index()); | 11171 PrintF(out, " %6d", entry.deoptimization_index()); |
| 11177 } else { | 11172 } else { |
| 11178 PrintF(out, " <none>"); | 11173 PrintF(out, " <none>"); |
| 11179 } | 11174 } |
| 11180 if (entry.argument_count() > 0) { | 11175 if (entry.argument_count() > 0) { |
| 11181 PrintF(out, " argc: %d", entry.argument_count()); | 11176 PrintF(out, " argc: %d", entry.argument_count()); |
| 11182 } | 11177 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 11203 PrintF(out, "\n"); | 11198 PrintF(out, "\n"); |
| 11204 } | 11199 } |
| 11205 #ifdef OBJECT_PRINT | 11200 #ifdef OBJECT_PRINT |
| 11206 if (!type_feedback_info()->IsUndefined()) { | 11201 if (!type_feedback_info()->IsUndefined()) { |
| 11207 TypeFeedbackInfo::cast(type_feedback_info())->TypeFeedbackInfoPrint(out); | 11202 TypeFeedbackInfo::cast(type_feedback_info())->TypeFeedbackInfoPrint(out); |
| 11208 PrintF(out, "\n"); | 11203 PrintF(out, "\n"); |
| 11209 } | 11204 } |
| 11210 #endif | 11205 #endif |
| 11211 } | 11206 } |
| 11212 | 11207 |
| 11213 PrintF("RelocInfo (size = %d)\n", relocation_size()); | 11208 PrintF(out, "RelocInfo (size = %d)\n", relocation_size()); |
| 11214 for (RelocIterator it(this); !it.done(); it.next()) { | 11209 for (RelocIterator it(this); !it.done(); it.next()) { |
| 11215 it.rinfo()->Print(GetIsolate(), out); | 11210 it.rinfo()->Print(GetIsolate(), out); |
| 11216 } | 11211 } |
| 11217 PrintF(out, "\n"); | 11212 PrintF(out, "\n"); |
| 11218 } | 11213 } |
| 11219 #endif // ENABLE_DISASSEMBLER | 11214 #endif // ENABLE_DISASSEMBLER |
| 11220 | 11215 |
| 11221 | 11216 |
| 11222 MaybeObject* JSObject::SetFastElementsCapacityAndLength( | 11217 MaybeObject* JSObject::SetFastElementsCapacityAndLength( |
| 11223 int capacity, | 11218 int capacity, |
| (...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12538 object->SetElement(index, *value, NONE, strict_mode, false), | 12533 object->SetElement(index, *value, NONE, strict_mode, false), |
| 12539 Object); | 12534 Object); |
| 12540 } | 12535 } |
| 12541 | 12536 |
| 12542 | 12537 |
| 12543 Handle<Object> JSObject::SetElement(Handle<JSObject> object, | 12538 Handle<Object> JSObject::SetElement(Handle<JSObject> object, |
| 12544 uint32_t index, | 12539 uint32_t index, |
| 12545 Handle<Object> value, | 12540 Handle<Object> value, |
| 12546 PropertyAttributes attr, | 12541 PropertyAttributes attr, |
| 12547 StrictModeFlag strict_mode, | 12542 StrictModeFlag strict_mode, |
| 12543 bool check_prototype, |
| 12548 SetPropertyMode set_mode) { | 12544 SetPropertyMode set_mode) { |
| 12549 if (object->HasExternalArrayElements()) { | 12545 if (object->HasExternalArrayElements()) { |
| 12550 if (!value->IsNumber() && !value->IsUndefined()) { | 12546 if (!value->IsNumber() && !value->IsUndefined()) { |
| 12551 bool has_exception; | 12547 bool has_exception; |
| 12552 Handle<Object> number = | 12548 Handle<Object> number = |
| 12553 Execution::ToNumber(object->GetIsolate(), value, &has_exception); | 12549 Execution::ToNumber(object->GetIsolate(), value, &has_exception); |
| 12554 if (has_exception) return Handle<Object>(); | 12550 if (has_exception) return Handle<Object>(); |
| 12555 value = number; | 12551 value = number; |
| 12556 } | 12552 } |
| 12557 } | 12553 } |
| 12558 CALL_HEAP_FUNCTION( | 12554 CALL_HEAP_FUNCTION( |
| 12559 object->GetIsolate(), | 12555 object->GetIsolate(), |
| 12560 object->SetElement(index, *value, attr, strict_mode, true, set_mode), | 12556 object->SetElement(index, *value, attr, strict_mode, check_prototype, |
| 12557 set_mode), |
| 12561 Object); | 12558 Object); |
| 12562 } | 12559 } |
| 12563 | 12560 |
| 12564 | 12561 |
| 12565 MaybeObject* JSObject::SetElement(uint32_t index, | 12562 MaybeObject* JSObject::SetElement(uint32_t index, |
| 12566 Object* value_raw, | 12563 Object* value_raw, |
| 12567 PropertyAttributes attributes, | 12564 PropertyAttributes attributes, |
| 12568 StrictModeFlag strict_mode, | 12565 StrictModeFlag strict_mode, |
| 12569 bool check_prototype, | 12566 bool check_prototype, |
| 12570 SetPropertyMode set_mode) { | 12567 SetPropertyMode set_mode) { |
| (...skipping 3962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16533 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16530 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16534 static const char* error_messages_[] = { | 16531 static const char* error_messages_[] = { |
| 16535 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16532 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16536 }; | 16533 }; |
| 16537 #undef ERROR_MESSAGES_TEXTS | 16534 #undef ERROR_MESSAGES_TEXTS |
| 16538 return error_messages_[reason]; | 16535 return error_messages_[reason]; |
| 16539 } | 16536 } |
| 16540 | 16537 |
| 16541 | 16538 |
| 16542 } } // namespace v8::internal | 16539 } } // namespace v8::internal |
| OLD | NEW |