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

Side by Side Diff: src/objects.cc

Issue 17853004: Generalize utilities to allow code templatization (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 | « src/objects.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 10093 matching lines...) Expand 10 before | Expand all | Expand 10 after
10104 return statement_position; 10104 return statement_position;
10105 } 10105 }
10106 10106
10107 10107
10108 SafepointEntry Code::GetSafepointEntry(Address pc) { 10108 SafepointEntry Code::GetSafepointEntry(Address pc) {
10109 SafepointTable table(this); 10109 SafepointTable table(this);
10110 return table.FindEntry(pc); 10110 return table.FindEntry(pc);
10111 } 10111 }
10112 10112
10113 10113
10114 Map* Code::FindFirstMap() { 10114 Object* Code::FindNthObject(int n, Map* match_map) {
10115 ASSERT(is_inline_cache_stub()); 10115 ASSERT(is_inline_cache_stub());
10116 DisallowHeapAllocation no_allocation; 10116 DisallowHeapAllocation no_allocation;
10117 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); 10117 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10118 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10118 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10119 RelocInfo* info = it.rinfo(); 10119 RelocInfo* info = it.rinfo();
10120 Object* object = info->target_object(); 10120 Object* object = info->target_object();
10121 if (object->IsMap()) return Map::cast(object); 10121 if (object->IsHeapObject()) {
10122 if (HeapObject::cast(object)->map() == match_map) {
10123 if (--n == 0) return object;
10124 }
10125 }
10122 } 10126 }
10123 return NULL; 10127 return NULL;
10124 } 10128 }
10125 10129
10126 10130
10127 void Code::ReplaceFirstMap(Map* replace_with) { 10131 Map* Code::FindFirstMap() {
10132 Object* result = FindNthObject(1, GetHeap()->meta_map());
10133 return (result != NULL) ? Map::cast(result) : NULL;
10134 }
10135
10136
10137 void Code::ReplaceNthObject(int n,
10138 Map* match_map,
10139 Object* replace_with) {
10128 ASSERT(is_inline_cache_stub()); 10140 ASSERT(is_inline_cache_stub());
10129 DisallowHeapAllocation no_allocation; 10141 DisallowHeapAllocation no_allocation;
10130 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); 10142 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10131 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10143 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10132 RelocInfo* info = it.rinfo(); 10144 RelocInfo* info = it.rinfo();
10133 Object* object = info->target_object(); 10145 Object* object = info->target_object();
10134 if (object->IsMap()) { 10146 if (object->IsHeapObject()) {
10135 info->set_target_object(replace_with); 10147 if (HeapObject::cast(object)->map() == match_map) {
10136 return; 10148 if (--n == 0) {
10149 info->set_target_object(replace_with);
10150 return;
10151 }
10152 }
10137 } 10153 }
10138 } 10154 }
10139 UNREACHABLE(); 10155 UNREACHABLE();
10140 } 10156 }
10141 10157
10142 10158
10143 void Code::FindAllMaps(MapHandleList* maps) { 10159 void Code::FindAllMaps(MapHandleList* maps) {
10144 ASSERT(is_inline_cache_stub()); 10160 ASSERT(is_inline_cache_stub());
10145 DisallowHeapAllocation no_allocation; 10161 DisallowHeapAllocation no_allocation;
10146 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); 10162 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10147 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10163 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10148 RelocInfo* info = it.rinfo(); 10164 RelocInfo* info = it.rinfo();
10149 Object* object = info->target_object(); 10165 Object* object = info->target_object();
10150 if (object->IsMap()) maps->Add(Handle<Map>(Map::cast(object))); 10166 if (object->IsMap()) maps->Add(Handle<Map>(Map::cast(object)));
10151 } 10167 }
10152 } 10168 }
10153 10169
10154 10170
10171 void Code::ReplaceFirstMap(Map* replace_with) {
10172 ReplaceNthObject(1, GetHeap()->meta_map(), replace_with);
10173 }
10174
10175
10155 Code* Code::FindFirstCode() { 10176 Code* Code::FindFirstCode() {
10156 ASSERT(is_inline_cache_stub()); 10177 ASSERT(is_inline_cache_stub());
10157 DisallowHeapAllocation no_allocation; 10178 DisallowHeapAllocation no_allocation;
10158 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); 10179 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET);
10159 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10180 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10160 RelocInfo* info = it.rinfo(); 10181 RelocInfo* info = it.rinfo();
10161 return Code::GetCodeFromTargetAddress(info->target_address()); 10182 return Code::GetCodeFromTargetAddress(info->target_address());
10162 } 10183 }
10163 return NULL; 10184 return NULL;
10164 } 10185 }
(...skipping 21 matching lines...) Expand all
10186 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); 10207 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
10187 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10208 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10188 RelocInfo* info = it.rinfo(); 10209 RelocInfo* info = it.rinfo();
10189 Object* object = info->target_object(); 10210 Object* object = info->target_object();
10190 if (object->IsName()) return Name::cast(object); 10211 if (object->IsName()) return Name::cast(object);
10191 } 10212 }
10192 return NULL; 10213 return NULL;
10193 } 10214 }
10194 10215
10195 10216
10217 void Code::ReplaceNthCell(int n, Cell* replace_with) {
10218 ASSERT(is_inline_cache_stub());
10219 DisallowHeapAllocation no_allocation;
10220 int mask = RelocInfo::ModeMask(RelocInfo::CELL);
10221 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10222 RelocInfo* info = it.rinfo();
10223 if (--n == 0) {
10224 info->set_target_cell(replace_with);
10225 return;
10226 }
10227 }
10228 UNREACHABLE();
10229 }
10230
10231
10196 void Code::ClearInlineCaches() { 10232 void Code::ClearInlineCaches() {
10197 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | 10233 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) |
10198 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) | 10234 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) |
10199 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID) | 10235 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID) |
10200 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_CONTEXT); 10236 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_CONTEXT);
10201 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10237 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10202 RelocInfo* info = it.rinfo(); 10238 RelocInfo* info = it.rinfo();
10203 Code* target(Code::GetCodeFromTargetAddress(info->target_address())); 10239 Code* target(Code::GetCodeFromTargetAddress(info->target_address()));
10204 if (target->is_inline_cache_stub()) { 10240 if (target->is_inline_cache_stub()) {
10205 IC::Clear(info->pc()); 10241 IC::Clear(info->pc());
(...skipping 5561 matching lines...) Expand 10 before | Expand all | Expand 10 after
15767 return static_cast<Type*>(type_raw()); 15803 return static_cast<Type*>(type_raw());
15768 } 15804 }
15769 15805
15770 15806
15771 void PropertyCell::set_type(Type* type, WriteBarrierMode ignored) { 15807 void PropertyCell::set_type(Type* type, WriteBarrierMode ignored) {
15772 set_type_raw(type, ignored); 15808 set_type_raw(type, ignored);
15773 } 15809 }
15774 15810
15775 15811
15776 } } // namespace v8::internal 15812 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698