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

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

Issue 239083005: Callers of Heap::AllocateStringFromOneByte() and Heap::AllocateStringFromUtf8() handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing review comments Created 6 years, 8 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.h ('k') | src/runtime.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 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 } 78 }
79 79
80 80
81 void PromotionQueue::ActivateGuardIfOnTheSamePage() { 81 void PromotionQueue::ActivateGuardIfOnTheSamePage() {
82 guard_ = guard_ || 82 guard_ = guard_ ||
83 heap_->new_space()->active_space()->current_page()->address() == 83 heap_->new_space()->active_space()->current_page()->address() ==
84 GetHeadPage()->address(); 84 GetHeadPage()->address();
85 } 85 }
86 86
87 87
88 MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str,
89 PretenureFlag pretenure) {
90 // Check for ASCII first since this is the common case.
91 const char* start = str.start();
92 int length = str.length();
93 int non_ascii_start = String::NonAsciiStart(start, length);
94 if (non_ascii_start >= length) {
95 // If the string is ASCII, we do not need to convert the characters
96 // since UTF8 is backwards compatible with ASCII.
97 return AllocateStringFromOneByte(str, pretenure);
98 }
99 // Non-ASCII and we need to decode.
100 return AllocateStringFromUtf8Slow(str, non_ascii_start, pretenure);
101 }
102
103
104 template<> 88 template<>
105 bool inline Heap::IsOneByte(Vector<const char> str, int chars) { 89 bool inline Heap::IsOneByte(Vector<const char> str, int chars) {
106 // TODO(dcarney): incorporate Latin-1 check when Latin-1 is supported? 90 // TODO(dcarney): incorporate Latin-1 check when Latin-1 is supported?
107 // ASCII only check. 91 // ASCII only check.
108 return chars == str.length(); 92 return chars == str.length();
109 } 93 }
110 94
111 95
112 template<> 96 template<>
113 bool inline Heap::IsOneByte(String* str, int chars) { 97 bool inline Heap::IsOneByte(String* str, int chars) {
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 792
809 793
810 double GCTracer::SizeOfHeapObjects() { 794 double GCTracer::SizeOfHeapObjects() {
811 return (static_cast<double>(heap_->SizeOfObjects())) / MB; 795 return (static_cast<double>(heap_->SizeOfObjects())) / MB;
812 } 796 }
813 797
814 798
815 } } // namespace v8::internal 799 } } // namespace v8::internal
816 800
817 #endif // V8_HEAP_INL_H_ 801 #endif // V8_HEAP_INL_H_
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698