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

Side by Side Diff: src/objects.cc

Issue 9402008: Uniformly handle 'undefined' store to Float64Array and Float32Array. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 8 years, 10 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 | test/cctest/test-api.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 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 11739 matching lines...) Expand 10 before | Expand all | Expand 10 after
11750 // converted to a number type further up in the call chain. 11750 // converted to a number type further up in the call chain.
11751 ASSERT(value->IsUndefined()); 11751 ASSERT(value->IsUndefined());
11752 } 11752 }
11753 set(index, cast_value); 11753 set(index, cast_value);
11754 } 11754 }
11755 return heap->NumberFromUint32(cast_value); 11755 return heap->NumberFromUint32(cast_value);
11756 } 11756 }
11757 11757
11758 11758
11759 MaybeObject* ExternalFloatArray::SetValue(uint32_t index, Object* value) { 11759 MaybeObject* ExternalFloatArray::SetValue(uint32_t index, Object* value) {
11760 float cast_value = 0; 11760 float cast_value = OS::nan_value();
11761 Heap* heap = GetHeap(); 11761 Heap* heap = GetHeap();
11762 if (index < static_cast<uint32_t>(length())) { 11762 if (index < static_cast<uint32_t>(length())) {
11763 if (value->IsSmi()) { 11763 if (value->IsSmi()) {
11764 int int_value = Smi::cast(value)->value(); 11764 int int_value = Smi::cast(value)->value();
11765 cast_value = static_cast<float>(int_value); 11765 cast_value = static_cast<float>(int_value);
11766 } else if (value->IsHeapNumber()) { 11766 } else if (value->IsHeapNumber()) {
11767 double double_value = HeapNumber::cast(value)->value(); 11767 double double_value = HeapNumber::cast(value)->value();
11768 cast_value = static_cast<float>(double_value); 11768 cast_value = static_cast<float>(double_value);
11769 } else { 11769 } else {
11770 // Clamp undefined to zero (default). All other types have been 11770 // Clamp undefined to NaN (default). All other types have been
11771 // converted to a number type further up in the call chain. 11771 // converted to a number type further up in the call chain.
11772 ASSERT(value->IsUndefined()); 11772 ASSERT(value->IsUndefined());
11773 } 11773 }
11774 set(index, cast_value); 11774 set(index, cast_value);
11775 } 11775 }
11776 return heap->AllocateHeapNumber(cast_value); 11776 return heap->AllocateHeapNumber(cast_value);
11777 } 11777 }
11778 11778
11779 11779
11780 MaybeObject* ExternalDoubleArray::SetValue(uint32_t index, Object* value) { 11780 MaybeObject* ExternalDoubleArray::SetValue(uint32_t index, Object* value) {
11781 double double_value = 0; 11781 double double_value = OS::nan_value();
11782 Heap* heap = GetHeap(); 11782 Heap* heap = GetHeap();
11783 if (index < static_cast<uint32_t>(length())) { 11783 if (index < static_cast<uint32_t>(length())) {
11784 if (value->IsSmi()) { 11784 if (value->IsSmi()) {
11785 int int_value = Smi::cast(value)->value(); 11785 int int_value = Smi::cast(value)->value();
11786 double_value = static_cast<double>(int_value); 11786 double_value = static_cast<double>(int_value);
11787 } else if (value->IsHeapNumber()) { 11787 } else if (value->IsHeapNumber()) {
11788 double_value = HeapNumber::cast(value)->value(); 11788 double_value = HeapNumber::cast(value)->value();
11789 } else { 11789 } else {
11790 // Clamp undefined to zero (default). All other types have been 11790 // Clamp undefined to NaN (default). All other types have been
11791 // converted to a number type further up in the call chain. 11791 // converted to a number type further up in the call chain.
11792 ASSERT(value->IsUndefined()); 11792 ASSERT(value->IsUndefined());
11793 } 11793 }
11794 set(index, double_value); 11794 set(index, double_value);
11795 } 11795 }
11796 return heap->AllocateHeapNumber(double_value); 11796 return heap->AllocateHeapNumber(double_value);
11797 } 11797 }
11798 11798
11799 11799
11800 JSGlobalPropertyCell* GlobalObject::GetPropertyCell(LookupResult* result) { 11800 JSGlobalPropertyCell* GlobalObject::GetPropertyCell(LookupResult* result) {
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
13071 if (break_point_objects()->IsUndefined()) return 0; 13071 if (break_point_objects()->IsUndefined()) return 0;
13072 // Single break point. 13072 // Single break point.
13073 if (!break_point_objects()->IsFixedArray()) return 1; 13073 if (!break_point_objects()->IsFixedArray()) return 1;
13074 // Multiple break points. 13074 // Multiple break points.
13075 return FixedArray::cast(break_point_objects())->length(); 13075 return FixedArray::cast(break_point_objects())->length();
13076 } 13076 }
13077 #endif // ENABLE_DEBUGGER_SUPPORT 13077 #endif // ENABLE_DEBUGGER_SUPPORT
13078 13078
13079 13079
13080 } } // namespace v8::internal 13080 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698