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

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

Issue 8231028: Ensure that the passed in raw pointer is not used in SetRaw(). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 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 | « runtime/vm/object.h ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/assert.h" 8 #include "vm/assert.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 // TODO(iposva): Get a proper halt instruction from the assembler. 670 // TODO(iposva): Get a proper halt instruction from the assembler.
671 uword address = heap->Allocate(size, space); 671 uword address = heap->Allocate(size, space);
672 NoGCScope no_gc; 672 NoGCScope no_gc;
673 InitializeObject(address, size); 673 InitializeObject(address, size);
674 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); 674 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag);
675 raw_obj->ptr()->class_ = cls.raw(); 675 raw_obj->ptr()->class_ = cls.raw();
676 return raw_obj; 676 return raw_obj;
677 } 677 }
678 678
679 679
680 #if defined(DEBUG)
681 void Object::ValidateHeapObject(RawObject* raw_obj) {
682 uword addr = RawObject::ToAddr(raw_obj);
683 ASSERT(Isolate::Current()->heap()->Contains(addr) ||
684 Dart::vm_isolate()->heap()->Contains(addr));
685 }
686 #endif // defined(DEBUG)
687
688
689 RawString* Class::Name() const { 680 RawString* Class::Name() const {
690 if (raw_ptr()->name_ != String::null()) { 681 if (raw_ptr()->name_ != String::null()) {
691 return raw_ptr()->name_; 682 return raw_ptr()->name_;
692 } 683 }
693 ASSERT(class_class() != null_); // Or GetSingletonClassIndex will not work. 684 ASSERT(class_class() != null_); // Or GetSingletonClassIndex will not work.
694 intptr_t index = GetSingletonClassIndex(raw()); 685 intptr_t index = GetSingletonClassIndex(raw());
695 return String::NewSymbol(GetSingletonClassName(index)); 686 return String::NewSymbol(GetSingletonClassName(index));
696 } 687 }
697 688
698 689
(...skipping 5586 matching lines...) Expand 10 before | Expand all | Expand 10 after
6285 const String& str = String::Handle(pattern()); 6276 const String& str = String::Handle(pattern());
6286 const char* format = "JSRegExp: pattern=%s flags=%s"; 6277 const char* format = "JSRegExp: pattern=%s flags=%s";
6287 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 6278 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
6288 char* chars = reinterpret_cast<char*>( 6279 char* chars = reinterpret_cast<char*>(
6289 Isolate::Current()->current_zone()->Allocate(len + 1)); 6280 Isolate::Current()->current_zone()->Allocate(len + 1));
6290 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 6281 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
6291 return chars; 6282 return chars;
6292 } 6283 }
6293 6284
6294 } // namespace dart 6285 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698