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

Side by Side Diff: src/heap-inl.h

Issue 11194053: Keep track of the first non-ascii word/char to avoid redoing the work. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 8 years, 2 months 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/heap.cc ('k') | src/objects.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 void PromotionQueue::ActivateGuardIfOnTheSamePage() { 78 void PromotionQueue::ActivateGuardIfOnTheSamePage() {
79 guard_ = guard_ || 79 guard_ = guard_ ||
80 heap_->new_space()->active_space()->current_page()->address() == 80 heap_->new_space()->active_space()->current_page()->address() ==
81 GetHeadPage()->address(); 81 GetHeadPage()->address();
82 } 82 }
83 83
84 84
85 MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str, 85 MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str,
86 PretenureFlag pretenure) { 86 PretenureFlag pretenure) {
87 // Check for ASCII first since this is the common case. 87 // Check for ASCII first since this is the common case.
88 if (String::IsAscii(str.start(), str.length())) { 88 const char* start = str.start();
89 int length = str.length();
90 int non_ascii_start = String::NonAsciiStart(start, length);
91 if (non_ascii_start >= length) {
89 // If the string is ASCII, we do not need to convert the characters 92 // If the string is ASCII, we do not need to convert the characters
90 // since UTF8 is backwards compatible with ASCII. 93 // since UTF8 is backwards compatible with ASCII.
91 return AllocateStringFromAscii(str, pretenure); 94 return AllocateStringFromAscii(str, pretenure);
92 } 95 }
93 // Non-ASCII and we need to decode. 96 // Non-ASCII and we need to decode.
94 return AllocateStringFromUtf8Slow(str, pretenure); 97 return AllocateStringFromUtf8Slow(str, non_ascii_start, pretenure);
95 } 98 }
96 99
97 100
98 MaybeObject* Heap::AllocateSymbol(Vector<const char> str, 101 MaybeObject* Heap::AllocateSymbol(Vector<const char> str,
99 int chars, 102 int chars,
100 uint32_t hash_field) { 103 uint32_t hash_field) {
101 unibrow::Utf8InputBuffer<> buffer(str.start(), 104 unibrow::Utf8InputBuffer<> buffer(str.start(),
102 static_cast<unsigned>(str.length())); 105 static_cast<unsigned>(str.length()));
103 return AllocateInternalSymbol(&buffer, chars, hash_field); 106 return AllocateInternalSymbol(&buffer, chars, hash_field);
104 } 107 }
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 AssertNoAllocation::~AssertNoAllocation() { } 804 AssertNoAllocation::~AssertNoAllocation() { }
802 DisableAssertNoAllocation::DisableAssertNoAllocation() { } 805 DisableAssertNoAllocation::DisableAssertNoAllocation() { }
803 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } 806 DisableAssertNoAllocation::~DisableAssertNoAllocation() { }
804 807
805 #endif 808 #endif
806 809
807 810
808 } } // namespace v8::internal 811 } } // namespace v8::internal
809 812
810 #endif // V8_HEAP_INL_H_ 813 #endif // V8_HEAP_INL_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698