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

Side by Side Diff: runtime/vm/symbols.cc

Issue 1303923002: Remove new space allocation in optimizing compiler, use Symbols::FromConcat where appropriate (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Optimize Symbols::FromConcat Created 5 years, 4 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
« runtime/vm/parser.cc ('K') | « runtime/vm/scanner.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/symbols.h" 5 #include "vm/symbols.h"
6 6
7 #include "vm/handles.h" 7 #include "vm/handles.h"
8 #include "vm/handles_impl.h" 8 #include "vm/handles_impl.h"
9 #include "vm/hash_table.h" 9 #include "vm/hash_table.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 return NewSymbol(UTF16Array(utf16_array, len)); 376 return NewSymbol(UTF16Array(utf16_array, len));
377 } 377 }
378 378
379 379
380 RawString* Symbols::FromUTF32(const int32_t* utf32_array, intptr_t len) { 380 RawString* Symbols::FromUTF32(const int32_t* utf32_array, intptr_t len) {
381 return NewSymbol(UTF32Array(utf32_array, len)); 381 return NewSymbol(UTF32Array(utf32_array, len));
382 } 382 }
383 383
384 384
385 RawString* Symbols::FromConcat(const String& str1, const String& str2) { 385 RawString* Symbols::FromConcat(const String& str1, const String& str2) {
386 return NewSymbol(ConcatString(str1, str2)); 386 if (str1.Length() == 0) {
387 return New(str2);
388 } else if (str2.Length() == 0) {
389 return New(str1);
390 } else {
391 return NewSymbol(ConcatString(str1, str2));
392 }
387 } 393 }
388 394
389 395
390 // StringType can be StringSlice, ConcatString, or {Latin1,UTF16,UTF32}Array. 396 // StringType can be StringSlice, ConcatString, or {Latin1,UTF16,UTF32}Array.
391 template<typename StringType> 397 template<typename StringType>
392 RawString* Symbols::NewSymbol(const StringType& str) { 398 RawString* Symbols::NewSymbol(const StringType& str) {
393 Thread* thread = Thread::Current(); 399 Thread* thread = Thread::Current();
394 Isolate* isolate = thread->isolate(); 400 Isolate* isolate = thread->isolate();
395 Zone* zone = thread->zone(); 401 Zone* zone = thread->zone();
396 String& symbol = String::Handle(zone); 402 String& symbol = String::Handle(zone);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { 469 RawObject* Symbols::GetVMSymbol(intptr_t object_id) {
464 ASSERT(IsVMSymbolId(object_id)); 470 ASSERT(IsVMSymbolId(object_id));
465 intptr_t i = (object_id - kMaxPredefinedObjectIds); 471 intptr_t i = (object_id - kMaxPredefinedObjectIds);
466 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { 472 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) {
467 return symbol_handles_[i]->raw(); 473 return symbol_handles_[i]->raw();
468 } 474 }
469 return Object::null(); 475 return Object::null();
470 } 476 }
471 477
472 } // namespace dart 478 } // namespace dart
OLDNEW
« runtime/vm/parser.cc ('K') | « runtime/vm/scanner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698