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

Side by Side Diff: src/conversions-inl.h

Issue 2106083002: Remove SealHandleScope from TryNumberToSize conversion (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | test/cctest/test-conversions.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_CONVERSIONS_INL_H_ 5 #ifndef V8_CONVERSIONS_INL_H_
6 #define V8_CONVERSIONS_INL_H_ 6 #define V8_CONVERSIONS_INL_H_
7 7
8 #include <float.h> // Required for DBL_MAX and on Win32 for finite() 8 #include <float.h> // Required for DBL_MAX and on Win32 for finite()
9 #include <limits.h> // Required for INT_MAX etc. 9 #include <limits.h> // Required for INT_MAX etc.
10 #include <stdarg.h> 10 #include <stdarg.h>
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 if (number->IsSmi()) return Smi::cast(number)->value(); 126 if (number->IsSmi()) return Smi::cast(number)->value();
127 return DoubleToUint32(number->Number()); 127 return DoubleToUint32(number->Number());
128 } 128 }
129 129
130 int64_t NumberToInt64(Object* number) { 130 int64_t NumberToInt64(Object* number) {
131 if (number->IsSmi()) return Smi::cast(number)->value(); 131 if (number->IsSmi()) return Smi::cast(number)->value();
132 return static_cast<int64_t>(number->Number()); 132 return static_cast<int64_t>(number->Number());
133 } 133 }
134 134
135 bool TryNumberToSize(Isolate* isolate, Object* number, size_t* result) { 135 bool TryNumberToSize(Isolate* isolate, Object* number, size_t* result) {
136 SealHandleScope shs(isolate); 136 // Do not create handles in this function! Don't use SealHandleScope because
137 // the function can be used concurrently.
137 if (number->IsSmi()) { 138 if (number->IsSmi()) {
138 int value = Smi::cast(number)->value(); 139 int value = Smi::cast(number)->value();
139 DCHECK(static_cast<unsigned>(Smi::kMaxValue) <= 140 DCHECK(static_cast<unsigned>(Smi::kMaxValue) <=
140 std::numeric_limits<size_t>::max()); 141 std::numeric_limits<size_t>::max());
141 if (value >= 0) { 142 if (value >= 0) {
142 *result = static_cast<size_t>(value); 143 *result = static_cast<size_t>(value);
143 return true; 144 return true;
144 } 145 }
145 return false; 146 return false;
146 } else { 147 } else {
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 buffer[buffer_pos] = '\0'; 759 buffer[buffer_pos] = '\0';
759 760
760 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); 761 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent);
761 return (sign == NEGATIVE) ? -converted : converted; 762 return (sign == NEGATIVE) ? -converted : converted;
762 } 763 }
763 764
764 } // namespace internal 765 } // namespace internal
765 } // namespace v8 766 } // namespace v8
766 767
767 #endif // V8_CONVERSIONS_INL_H_ 768 #endif // V8_CONVERSIONS_INL_H_
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-conversions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698