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

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

Issue 326243002: - Ensure positive keys for private mangling. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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 | « no previous file | 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 9293 matching lines...) Expand 10 before | Expand all | Expand 10 after
9304 if (lib_key == key) { 9304 if (lib_key == key) {
9305 return true; 9305 return true;
9306 } 9306 }
9307 } 9307 }
9308 return false; 9308 return false;
9309 } 9309 }
9310 9310
9311 9311
9312 void Library::AllocatePrivateKey() const { 9312 void Library::AllocatePrivateKey() const {
9313 const String& url = String::Handle(this->url()); 9313 const String& url = String::Handle(this->url());
9314 intptr_t key_value = url.Hash(); 9314 intptr_t key_value = url.Hash() & kIntptrMax;
9315 while (Library::IsKeyUsed(key_value)) { 9315 while ((key_value == 0) || Library::IsKeyUsed(key_value)) {
9316 key_value++; 9316 key_value = (key_value + 1) & kIntptrMax;
9317 } 9317 }
9318 ASSERT(key_value > 0);
9318 char private_key[32]; 9319 char private_key[32];
9319 OS::SNPrint(private_key, sizeof(private_key), 9320 OS::SNPrint(private_key, sizeof(private_key),
9320 "%c%" Pd "", kPrivateKeySeparator, key_value); 9321 "%c%" Pd "", kPrivateKeySeparator, key_value);
9321 StorePointer(&raw_ptr()->private_key_, String::New(private_key, Heap::kOld)); 9322 StorePointer(&raw_ptr()->private_key_, String::New(private_key, Heap::kOld));
9322 } 9323 }
9323 9324
9324 9325
9325 const String& Library::PrivateCoreLibName(const String& member) { 9326 const String& Library::PrivateCoreLibName(const String& member) {
9326 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 9327 const Library& core_lib = Library::Handle(Library::CoreLibrary());
9327 const String& private_name = String::ZoneHandle(core_lib.PrivateName(member)); 9328 const String& private_name = String::ZoneHandle(core_lib.PrivateName(member));
(...skipping 9690 matching lines...) Expand 10 before | Expand all | Expand 10 after
19018 return tag_label.ToCString(); 19019 return tag_label.ToCString();
19019 } 19020 }
19020 19021
19021 19022
19022 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 19023 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
19023 Instance::PrintJSONImpl(stream, ref); 19024 Instance::PrintJSONImpl(stream, ref);
19024 } 19025 }
19025 19026
19026 19027
19027 } // namespace dart 19028 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698