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

Unified Diff: src/heap.cc

Issue 390004: Fix warnings on Win64. (Closed)
Patch Set: Created 11 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« src/api.cc ('K') | « src/handles.cc ('k') | src/ic.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index 685cbea99737bb51afe535379c4fb04f4fc7da42..8de945505036f1638df233654716c7698ba2699c 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -1872,20 +1872,23 @@ Object* Heap::AllocateSubString(String* buffer,
Object* Heap::AllocateExternalStringFromAscii(
ExternalAsciiString::Resource* resource) {
Map* map;
- int length = resource->length();
- if (length <= String::kMaxShortSize) {
+ size_t length = resource->length();
+ if (length <= static_cast<size_t>(String::kMaxShortSize)) {
map = short_external_ascii_string_map();
- } else if (length <= String::kMaxMediumSize) {
+ } else if (length <= static_cast<size_t>(String::kMaxMediumSize)) {
map = medium_external_ascii_string_map();
- } else {
+ } else if (length <= static_cast<size_t>(String::kMaxLength)) {
map = long_external_ascii_string_map();
+ } else {
+ Top::context()->mark_out_of_memory();
+ return Failure::OutOfMemoryException();
}
Object* result = Allocate(map, NEW_SPACE);
if (result->IsFailure()) return result;
ExternalAsciiString* external_string = ExternalAsciiString::cast(result);
- external_string->set_length(length);
+ external_string->set_length(static_cast<int>(length));
external_string->set_resource(resource);
return result;
@@ -1894,14 +1897,17 @@ Object* Heap::AllocateExternalStringFromAscii(
Object* Heap::AllocateExternalStringFromTwoByte(
ExternalTwoByteString::Resource* resource) {
- int length = resource->length();
-
- Map* map = ExternalTwoByteString::StringMap(length);
+ size_t length = resource->length();
+ if (length > static_cast<size_t>(String::kMaxLength)) {
+ Top::context()->mark_out_of_memory();
+ return Failure::OutOfMemoryException();
+ }
+ Map* map = ExternalTwoByteString::StringMap(static_cast<int>(length));
Object* result = Allocate(map, NEW_SPACE);
if (result->IsFailure()) return result;
ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result);
- external_string->set_length(length);
+ external_string->set_length(static_cast<int>(length));
external_string->set_resource(resource);
return result;
« src/api.cc ('K') | « src/handles.cc ('k') | src/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698