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

Side by Side Diff: src/hydrogen-instructions.cc

Issue 19562003: Add support for IncrementCounter in Hydrogen. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Using HConstant, HLoadKeyed, HAdd and HStoreKeyed. Created 7 years, 5 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 Verify(); 418 Verify();
419 #endif 419 #endif
420 return may_overflow; 420 return may_overflow;
421 } 421 }
422 422
423 423
424 const char* HType::ToString() { 424 const char* HType::ToString() {
425 // Note: The c1visualizer syntax for locals allows only a sequence of the 425 // Note: The c1visualizer syntax for locals allows only a sequence of the
426 // following characters: A-Za-z0-9_-|: 426 // following characters: A-Za-z0-9_-|:
427 switch (type_) { 427 switch (type_) {
428 case kNone: return "none";
428 case kTagged: return "tagged"; 429 case kTagged: return "tagged";
429 case kTaggedPrimitive: return "primitive"; 430 case kTaggedPrimitive: return "primitive";
430 case kTaggedNumber: return "number"; 431 case kTaggedNumber: return "number";
431 case kSmi: return "smi"; 432 case kSmi: return "smi";
432 case kHeapNumber: return "heap-number"; 433 case kHeapNumber: return "heap-number";
433 case kString: return "string"; 434 case kString: return "string";
434 case kBoolean: return "boolean"; 435 case kBoolean: return "boolean";
435 case kNonPrimitive: return "non-primitive"; 436 case kNonPrimitive: return "non-primitive";
436 case kJSArray: return "array"; 437 case kJSArray: return "array";
437 case kJSObject: return "object"; 438 case kJSObject: return "object";
(...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after
2164 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value); 2165 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value);
2165 } 2166 }
2166 2167
2167 2168
2168 HConstant::HConstant(Handle<Object> handle, Representation r) 2169 HConstant::HConstant(Handle<Object> handle, Representation r)
2169 : handle_(handle), 2170 : handle_(handle),
2170 unique_id_(), 2171 unique_id_(),
2171 has_smi_value_(false), 2172 has_smi_value_(false),
2172 has_int32_value_(false), 2173 has_int32_value_(false),
2173 has_double_value_(false), 2174 has_double_value_(false),
2175 has_external_value_(false),
2174 is_internalized_string_(false), 2176 is_internalized_string_(false),
2175 is_not_in_new_space_(true), 2177 is_not_in_new_space_(true),
2176 is_cell_(false), 2178 is_cell_(false),
2177 boolean_value_(handle->BooleanValue()) { 2179 boolean_value_(handle->BooleanValue()),
2180 external_value_(ExternalReference::null()) {
2178 if (handle_->IsHeapObject()) { 2181 if (handle_->IsHeapObject()) {
2179 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap(); 2182 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap();
2180 is_not_in_new_space_ = !heap->InNewSpace(*handle); 2183 is_not_in_new_space_ = !heap->InNewSpace(*handle);
2181 } 2184 }
2182 if (handle_->IsNumber()) { 2185 if (handle_->IsNumber()) {
2183 double n = handle_->Number(); 2186 double n = handle_->Number();
2184 has_int32_value_ = IsInteger32(n); 2187 has_int32_value_ = IsInteger32(n);
2185 int32_value_ = DoubleToInt32(n); 2188 int32_value_ = DoubleToInt32(n);
2186 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); 2189 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_);
2187 double_value_ = n; 2190 double_value_ = n;
(...skipping 10 matching lines...) Expand all
2198 2201
2199 2202
2200 HConstant::HConstant(Handle<Object> handle, 2203 HConstant::HConstant(Handle<Object> handle,
2201 UniqueValueId unique_id, 2204 UniqueValueId unique_id,
2202 Representation r, 2205 Representation r,
2203 HType type, 2206 HType type,
2204 bool is_internalize_string, 2207 bool is_internalize_string,
2205 bool is_not_in_new_space, 2208 bool is_not_in_new_space,
2206 bool is_cell, 2209 bool is_cell,
2207 bool boolean_value) 2210 bool boolean_value)
2208 : handle_(handle), 2211 : handle_(handle),
2209 unique_id_(unique_id), 2212 unique_id_(unique_id),
2210 has_smi_value_(false), 2213 has_smi_value_(false),
2211 has_int32_value_(false), 2214 has_int32_value_(false),
2212 has_double_value_(false), 2215 has_double_value_(false),
2213 is_internalized_string_(is_internalize_string), 2216 has_external_value_(false),
2214 is_not_in_new_space_(is_not_in_new_space), 2217 is_internalized_string_(is_internalize_string),
2215 is_cell_(is_cell), 2218 is_not_in_new_space_(is_not_in_new_space),
2216 boolean_value_(boolean_value), 2219 is_cell_(is_cell),
2217 type_from_value_(type) { 2220 boolean_value_(boolean_value),
2221 external_value_(ExternalReference::null()),
2222 type_from_value_(type) {
2218 ASSERT(!handle.is_null()); 2223 ASSERT(!handle.is_null());
2219 ASSERT(!type.IsUninitialized()); 2224 ASSERT(!type.IsUninitialized());
2220 ASSERT(!type.IsTaggedNumber()); 2225 ASSERT(!type.IsTaggedNumber());
2221 Initialize(r); 2226 Initialize(r);
2222 } 2227 }
2223 2228
2224 2229
2225 HConstant::HConstant(int32_t integer_value, 2230 HConstant::HConstant(int32_t integer_value,
2226 Representation r, 2231 Representation r,
2227 bool is_not_in_new_space, 2232 bool is_not_in_new_space,
2228 Handle<Object> optional_handle) 2233 Handle<Object> optional_handle)
2229 : handle_(optional_handle), 2234 : handle_(optional_handle),
2230 unique_id_(), 2235 unique_id_(),
2231 has_int32_value_(true), 2236 has_int32_value_(true),
2232 has_double_value_(true), 2237 has_double_value_(true),
2233 is_internalized_string_(false), 2238 has_external_value_(false),
2234 is_not_in_new_space_(is_not_in_new_space), 2239 is_internalized_string_(false),
2235 is_cell_(false), 2240 is_not_in_new_space_(is_not_in_new_space),
2236 boolean_value_(integer_value != 0), 2241 is_cell_(false),
2237 int32_value_(integer_value), 2242 boolean_value_(integer_value != 0),
2238 double_value_(FastI2D(integer_value)) { 2243 int32_value_(integer_value),
2244 double_value_(FastI2D(integer_value)),
2245 external_value_(ExternalReference::null()) {
2239 has_smi_value_ = Smi::IsValid(int32_value_); 2246 has_smi_value_ = Smi::IsValid(int32_value_);
2240 Initialize(r); 2247 Initialize(r);
2241 } 2248 }
2242 2249
2243 2250
2244 HConstant::HConstant(double double_value, 2251 HConstant::HConstant(double double_value,
2245 Representation r, 2252 Representation r,
2246 bool is_not_in_new_space, 2253 bool is_not_in_new_space,
2247 Handle<Object> optional_handle) 2254 Handle<Object> optional_handle)
2248 : handle_(optional_handle), 2255 : handle_(optional_handle),
2249 unique_id_(), 2256 unique_id_(),
2250 has_int32_value_(IsInteger32(double_value)), 2257 has_int32_value_(IsInteger32(double_value)),
2251 has_double_value_(true), 2258 has_double_value_(true),
2252 is_internalized_string_(false), 2259 has_external_value_(false),
2253 is_not_in_new_space_(is_not_in_new_space), 2260 is_internalized_string_(false),
2254 is_cell_(false), 2261 is_not_in_new_space_(is_not_in_new_space),
2255 boolean_value_(double_value != 0 && !std::isnan(double_value)), 2262 is_cell_(false),
2256 int32_value_(DoubleToInt32(double_value)), 2263 boolean_value_(double_value != 0 && !std::isnan(double_value)),
2257 double_value_(double_value) { 2264 int32_value_(DoubleToInt32(double_value)),
2265 double_value_(double_value),
2266 external_value_(ExternalReference::null()) {
2258 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); 2267 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_);
2259 Initialize(r); 2268 Initialize(r);
2260 } 2269 }
2261 2270
2262 2271
2272 HConstant::HConstant(ExternalReference reference, Representation r)
2273 : has_smi_value_(false),
2274 has_int32_value_(false),
2275 has_double_value_(false),
2276 has_external_value_(true),
2277 is_internalized_string_(false),
2278 is_not_in_new_space_(true),
2279 is_cell_(false),
2280 boolean_value_(true),
2281 external_value_(reference) {
2282 Initialize(r);
2283 }
2284
2285
2263 void HConstant::Initialize(Representation r) { 2286 void HConstant::Initialize(Representation r) {
2264 if (r.IsNone()) { 2287 if (r.IsNone()) {
2265 if (has_smi_value_) { 2288 if (has_smi_value_) {
2266 r = Representation::Smi(); 2289 r = Representation::Smi();
2267 } else if (has_int32_value_) { 2290 } else if (has_int32_value_) {
2268 r = Representation::Integer32(); 2291 r = Representation::Integer32();
2269 } else if (has_double_value_) { 2292 } else if (has_double_value_) {
2270 r = Representation::Double(); 2293 r = Representation::Double();
2294 } else if (has_external_value_) {
2295 r = Representation::External();
2271 } else { 2296 } else {
2272 r = Representation::Tagged(); 2297 r = Representation::Tagged();
2273 } 2298 }
2274 } 2299 }
2275 set_representation(r); 2300 set_representation(r);
2276 SetFlag(kUseGVN); 2301 SetFlag(kUseGVN);
2277 } 2302 }
2278 2303
2279 2304
2280 bool HConstant::EmitAtUses() { 2305 bool HConstant::EmitAtUses() {
(...skipping 10 matching lines...) Expand all
2291 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { 2316 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const {
2292 if (r.IsSmi() && !has_smi_value_) return NULL; 2317 if (r.IsSmi() && !has_smi_value_) return NULL;
2293 if (r.IsInteger32() && !has_int32_value_) return NULL; 2318 if (r.IsInteger32() && !has_int32_value_) return NULL;
2294 if (r.IsDouble() && !has_double_value_) return NULL; 2319 if (r.IsDouble() && !has_double_value_) return NULL;
2295 if (has_int32_value_) { 2320 if (has_int32_value_) {
2296 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_); 2321 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_);
2297 } 2322 }
2298 if (has_double_value_) { 2323 if (has_double_value_) {
2299 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_); 2324 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_);
2300 } 2325 }
2326 if (has_external_value_) {
2327 return new(zone) HConstant(external_value_, r);
2328 }
2301 ASSERT(!handle_.is_null()); 2329 ASSERT(!handle_.is_null());
2302 return new(zone) HConstant(handle_, 2330 return new(zone) HConstant(handle_,
2303 unique_id_, 2331 unique_id_,
2304 r, 2332 r,
2305 type_from_value_, 2333 type_from_value_,
2306 is_internalized_string_, 2334 is_internalized_string_,
2307 is_not_in_new_space_, 2335 is_not_in_new_space_,
2308 is_cell_, 2336 is_cell_,
2309 boolean_value_); 2337 boolean_value_);
2310 } 2338 }
(...skipping 14 matching lines...) Expand all
2325 } 2353 }
2326 return NULL; 2354 return NULL;
2327 } 2355 }
2328 2356
2329 2357
2330 void HConstant::PrintDataTo(StringStream* stream) { 2358 void HConstant::PrintDataTo(StringStream* stream) {
2331 if (has_int32_value_) { 2359 if (has_int32_value_) {
2332 stream->Add("%d ", int32_value_); 2360 stream->Add("%d ", int32_value_);
2333 } else if (has_double_value_) { 2361 } else if (has_double_value_) {
2334 stream->Add("%f ", FmtElm(double_value_)); 2362 stream->Add("%f ", FmtElm(double_value_));
2363 } else if (has_external_value_) {
2364 stream->Add("%p ", reinterpret_cast<void*>(external_value_.address()));
2335 } else { 2365 } else {
2336 handle()->ShortPrint(stream); 2366 handle()->ShortPrint(stream);
2337 } 2367 }
2338 } 2368 }
2339 2369
2340 2370
2341 void HBinaryOperation::PrintDataTo(StringStream* stream) { 2371 void HBinaryOperation::PrintDataTo(StringStream* stream) {
2342 left()->PrintNameTo(stream); 2372 left()->PrintNameTo(stream);
2343 stream->Add(" "); 2373 stream->Add(" ");
2344 right()->PrintNameTo(stream); 2374 right()->PrintNameTo(stream);
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
3114 } 3144 }
3115 return result; 3145 return result;
3116 } 3146 }
3117 3147
3118 3148
3119 HType HConstant::CalculateInferredType() { 3149 HType HConstant::CalculateInferredType() {
3120 if (has_int32_value_) { 3150 if (has_int32_value_) {
3121 return Smi::IsValid(int32_value_) ? HType::Smi() : HType::HeapNumber(); 3151 return Smi::IsValid(int32_value_) ? HType::Smi() : HType::HeapNumber();
3122 } 3152 }
3123 if (has_double_value_) return HType::HeapNumber(); 3153 if (has_double_value_) return HType::HeapNumber();
3154 if (has_external_value_) return HType::None();
3124 ASSERT(!type_from_value_.IsUninitialized()); 3155 ASSERT(!type_from_value_.IsUninitialized());
3125 return type_from_value_; 3156 return type_from_value_;
3126 } 3157 }
3127 3158
3128 3159
3129 HType HCompareGeneric::CalculateInferredType() { 3160 HType HCompareGeneric::CalculateInferredType() {
3130 return HType::Boolean(); 3161 return HType::Boolean();
3131 } 3162 }
3132 3163
3133 3164
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
3971 case kBackingStore: 4002 case kBackingStore:
3972 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); 4003 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString());
3973 stream->Add("[backing-store]"); 4004 stream->Add("[backing-store]");
3974 break; 4005 break;
3975 } 4006 }
3976 4007
3977 stream->Add("@%d", offset()); 4008 stream->Add("@%d", offset());
3978 } 4009 }
3979 4010
3980 } } // namespace v8::internal 4011 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698