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

Side by Side Diff: src/global-handles.cc

Issue 22795004: abstract eternal into class (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comments addressed Created 7 years, 3 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/global-handles.h ('k') | test/cctest/test-global-handles.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 } 1013 }
1014 } 1014 }
1015 object_group_connections_.Clear(); 1015 object_group_connections_.Clear();
1016 object_group_connections_.Initialize(kObjectGroupConnectionsCapacity); 1016 object_group_connections_.Initialize(kObjectGroupConnectionsCapacity);
1017 retainer_infos_.Clear(); 1017 retainer_infos_.Clear();
1018 implicit_ref_connections_.Clear(); 1018 implicit_ref_connections_.Clear();
1019 } 1019 }
1020 1020
1021 1021
1022 EternalHandles::EternalHandles() : size_(0) { 1022 EternalHandles::EternalHandles() : size_(0) {
1023 STATIC_ASSERT(v8::kUninitializedEternalIndex == kInvalidIndex);
1024 for (unsigned i = 0; i < ARRAY_SIZE(singleton_handles_); i++) { 1023 for (unsigned i = 0; i < ARRAY_SIZE(singleton_handles_); i++) {
1025 singleton_handles_[i] = kInvalidIndex; 1024 singleton_handles_[i] = kInvalidIndex;
1026 } 1025 }
1027 } 1026 }
1028 1027
1029 1028
1030 EternalHandles::~EternalHandles() { 1029 EternalHandles::~EternalHandles() {
1031 for (int i = 0; i < blocks_.length(); i++) delete[] blocks_[i]; 1030 for (int i = 0; i < blocks_.length(); i++) delete[] blocks_[i];
1032 } 1031 }
1033 1032
(...skipping 21 matching lines...) Expand all
1055 for (int i = 0; i < new_space_indices_.length(); i++) { 1054 for (int i = 0; i < new_space_indices_.length(); i++) {
1056 int index = new_space_indices_[i]; 1055 int index = new_space_indices_[i];
1057 if (heap->InNewSpace(*GetLocation(index))) { 1056 if (heap->InNewSpace(*GetLocation(index))) {
1058 new_space_indices_[last++] = index; 1057 new_space_indices_[last++] = index;
1059 } 1058 }
1060 } 1059 }
1061 new_space_indices_.Rewind(last); 1060 new_space_indices_.Rewind(last);
1062 } 1061 }
1063 1062
1064 1063
1065 int EternalHandles::Create(Isolate* isolate, Object* object) { 1064 void EternalHandles::Create(Isolate* isolate, Object* object, int* index) {
1066 if (object == NULL) return kInvalidIndex; 1065 ASSERT_EQ(kInvalidIndex, *index);
1066 if (object == NULL) return;
1067 ASSERT_NE(isolate->heap()->the_hole_value(), object); 1067 ASSERT_NE(isolate->heap()->the_hole_value(), object);
1068 int block = size_ >> kShift; 1068 int block = size_ >> kShift;
1069 int offset = size_ & kMask; 1069 int offset = size_ & kMask;
1070 // need to resize 1070 // need to resize
1071 if (offset == 0) { 1071 if (offset == 0) {
1072 Object** next_block = new Object*[kSize]; 1072 Object** next_block = new Object*[kSize];
1073 Object* the_hole = isolate->heap()->the_hole_value(); 1073 Object* the_hole = isolate->heap()->the_hole_value();
1074 MemsetPointer(next_block, the_hole, kSize); 1074 MemsetPointer(next_block, the_hole, kSize);
1075 blocks_.Add(next_block); 1075 blocks_.Add(next_block);
1076 } 1076 }
1077 ASSERT_EQ(isolate->heap()->the_hole_value(), blocks_[block][offset]); 1077 ASSERT_EQ(isolate->heap()->the_hole_value(), blocks_[block][offset]);
1078 blocks_[block][offset] = object; 1078 blocks_[block][offset] = object;
1079 if (isolate->heap()->InNewSpace(object)) { 1079 if (isolate->heap()->InNewSpace(object)) {
1080 new_space_indices_.Add(size_); 1080 new_space_indices_.Add(size_);
1081 } 1081 }
1082 return size_++; 1082 *index = size_++;
1083 } 1083 }
1084 1084
1085 1085
1086 } } // namespace v8::internal 1086 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/global-handles.h ('k') | test/cctest/test-global-handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698