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

Side by Side Diff: src/objects.cc

Issue 159537: Merge r2564 to branches/1.2:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/1.2/
Patch Set: Created 11 years, 4 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 | src/version.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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-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 7038 matching lines...) Expand 10 before | Expand all | Expand 10 after
7049 } 7049 }
7050 ASSERT_NE(NULL, result_double); 7050 ASSERT_NE(NULL, result_double);
7051 result_double->set_value(static_cast<double>(result)); 7051 result_double->set_value(static_cast<double>(result));
7052 return result_double; 7052 return result_double;
7053 } 7053 }
7054 7054
7055 7055
7056 Object* PixelArray::SetValue(uint32_t index, Object* value) { 7056 Object* PixelArray::SetValue(uint32_t index, Object* value) {
7057 uint8_t clamped_value = 0; 7057 uint8_t clamped_value = 0;
7058 if (index < static_cast<uint32_t>(length())) { 7058 if (index < static_cast<uint32_t>(length())) {
7059 int int_value = 0;
7060 if (value->IsSmi()) { 7059 if (value->IsSmi()) {
7061 int_value = Smi::cast(value)->value(); 7060 int int_value = Smi::cast(value)->value();
7061 if (int_value < 0) {
7062 clamped_value = 0;
7063 } else if (int_value > 255) {
7064 clamped_value = 255;
7065 } else {
7066 clamped_value = static_cast<uint8_t>(int_value);
7067 }
7062 } else if (value->IsHeapNumber()) { 7068 } else if (value->IsHeapNumber()) {
7063 double double_value = HeapNumber::cast(value)->value(); 7069 double double_value = HeapNumber::cast(value)->value();
7064 if (!isnan(double_value)) { 7070 if (!(double_value > 0)) {
7065 // NaN clamps to zero (default). Other doubles are rounded to 7071 // NaN and less than zero clamp to zero.
7066 // the nearest integer. 7072 clamped_value = 0;
7067 int_value = static_cast<int>(double_value + 0.5); 7073 } else if (double_value > 255) {
7074 // Greater than 255 clamp to 255.
7075 clamped_value = 255;
7076 } else {
7077 // Other doubles are rounded to the nearest integer.
7078 clamped_value = static_cast<uint8_t>(double_value + 0.5);
7068 } 7079 }
7069 } else { 7080 } else {
7070 // Clamp undefined to zero (default). All other types have been 7081 // Clamp undefined to zero (default). All other types have been
7071 // converted to a number type further up in the call chain. 7082 // converted to a number type further up in the call chain.
7072 ASSERT(value->IsUndefined()); 7083 ASSERT(value->IsUndefined());
7073 } 7084 }
7074 if (int_value < 0) {
7075 clamped_value = 0;
7076 } else if (int_value > 255) {
7077 clamped_value = 255;
7078 } else {
7079 clamped_value = static_cast<uint8_t>(int_value);
7080 }
7081 set(index, clamped_value); 7085 set(index, clamped_value);
7082 } 7086 }
7083 return Smi::FromInt(clamped_value); 7087 return Smi::FromInt(clamped_value);
7084 } 7088 }
7085 7089
7086 7090
7087 Object* GlobalObject::GetPropertyCell(LookupResult* result) { 7091 Object* GlobalObject::GetPropertyCell(LookupResult* result) {
7088 ASSERT(!HasFastProperties()); 7092 ASSERT(!HasFastProperties());
7089 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); 7093 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry());
7090 ASSERT(value->IsJSGlobalPropertyCell()); 7094 ASSERT(value->IsJSGlobalPropertyCell());
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
7993 if (break_point_objects()->IsUndefined()) return 0; 7997 if (break_point_objects()->IsUndefined()) return 0;
7994 // Single beak point. 7998 // Single beak point.
7995 if (!break_point_objects()->IsFixedArray()) return 1; 7999 if (!break_point_objects()->IsFixedArray()) return 1;
7996 // Multiple break points. 8000 // Multiple break points.
7997 return FixedArray::cast(break_point_objects())->length(); 8001 return FixedArray::cast(break_point_objects())->length();
7998 } 8002 }
7999 #endif 8003 #endif
8000 8004
8001 8005
8002 } } // namespace v8::internal 8006 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698