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

Side by Side Diff: src/heap.cc

Issue 240053010: Return Object* instead of MaybeObject* from runtime calls. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: cmpp Created 6 years, 8 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 | « src/execution.cc ('k') | src/heap-inl.h » ('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 2481 matching lines...) Expand 10 before | Expand all | Expand 10 after
2492 set_null_value(Oddball::cast(obj)); 2492 set_null_value(Oddball::cast(obj));
2493 Oddball::cast(obj)->set_kind(Oddball::kNull); 2493 Oddball::cast(obj)->set_kind(Oddball::kNull);
2494 2494
2495 { MaybeObject* maybe_obj = Allocate(undefined_map(), OLD_POINTER_SPACE); 2495 { MaybeObject* maybe_obj = Allocate(undefined_map(), OLD_POINTER_SPACE);
2496 if (!maybe_obj->ToObject(&obj)) return false; 2496 if (!maybe_obj->ToObject(&obj)) return false;
2497 } 2497 }
2498 set_undefined_value(Oddball::cast(obj)); 2498 set_undefined_value(Oddball::cast(obj));
2499 Oddball::cast(obj)->set_kind(Oddball::kUndefined); 2499 Oddball::cast(obj)->set_kind(Oddball::kUndefined);
2500 ASSERT(!InNewSpace(undefined_value())); 2500 ASSERT(!InNewSpace(undefined_value()));
2501 2501
2502 // Set preliminary exception sentinel value before actually initializing it.
2503 set_exception(null_value());
2504
2502 // Allocate the empty descriptor array. 2505 // Allocate the empty descriptor array.
2503 { MaybeObject* maybe_obj = AllocateEmptyFixedArray(); 2506 { MaybeObject* maybe_obj = AllocateEmptyFixedArray();
2504 if (!maybe_obj->ToObject(&obj)) return false; 2507 if (!maybe_obj->ToObject(&obj)) return false;
2505 } 2508 }
2506 set_empty_descriptor_array(DescriptorArray::cast(obj)); 2509 set_empty_descriptor_array(DescriptorArray::cast(obj));
2507 2510
2508 // Allocate the constant pool array. 2511 // Allocate the constant pool array.
2509 { MaybeObject* maybe_obj = AllocateEmptyConstantPoolArray(); 2512 { MaybeObject* maybe_obj = AllocateEmptyConstantPoolArray();
2510 if (!maybe_obj->ToObject(&obj)) return false; 2513 if (!maybe_obj->ToObject(&obj)) return false;
2511 } 2514 }
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after
3969 decoder(isolate_->unicode_cache()->utf8_decoder()); 3972 decoder(isolate_->unicode_cache()->utf8_decoder());
3970 decoder->Reset(string.start() + non_ascii_start, 3973 decoder->Reset(string.start() + non_ascii_start,
3971 string.length() - non_ascii_start); 3974 string.length() - non_ascii_start);
3972 int utf16_length = decoder->Utf16Length(); 3975 int utf16_length = decoder->Utf16Length();
3973 ASSERT(utf16_length > 0); 3976 ASSERT(utf16_length > 0);
3974 // Allocate string. 3977 // Allocate string.
3975 Object* result; 3978 Object* result;
3976 { 3979 {
3977 int chars = non_ascii_start + utf16_length; 3980 int chars = non_ascii_start + utf16_length;
3978 MaybeObject* maybe_result = AllocateRawTwoByteString(chars, pretenure); 3981 MaybeObject* maybe_result = AllocateRawTwoByteString(chars, pretenure);
3979 if (!maybe_result->ToObject(&result)) return maybe_result; 3982 if (!maybe_result->ToObject(&result) || result->IsException()) {
3983 return maybe_result;
3984 }
3980 } 3985 }
3981 // Convert and copy the characters into the new object. 3986 // Convert and copy the characters into the new object.
3982 SeqTwoByteString* twobyte = SeqTwoByteString::cast(result); 3987 SeqTwoByteString* twobyte = SeqTwoByteString::cast(result);
3983 // Copy ascii portion. 3988 // Copy ascii portion.
3984 uint16_t* data = twobyte->GetChars(); 3989 uint16_t* data = twobyte->GetChars();
3985 if (non_ascii_start != 0) { 3990 if (non_ascii_start != 0) {
3986 const char* ascii_data = string.start(); 3991 const char* ascii_data = string.start();
3987 for (int i = 0; i < non_ascii_start; i++) { 3992 for (int i = 0; i < non_ascii_start; i++) {
3988 *data++ = *ascii_data++; 3993 *data++ = *ascii_data++;
3989 } 3994 }
3990 } 3995 }
3991 // Now write the remainder. 3996 // Now write the remainder.
3992 decoder->WriteUtf16(data, utf16_length); 3997 decoder->WriteUtf16(data, utf16_length);
3993 return result; 3998 return result;
3994 } 3999 }
3995 4000
3996 4001
3997 MaybeObject* Heap::AllocateStringFromTwoByte(Vector<const uc16> string, 4002 MaybeObject* Heap::AllocateStringFromTwoByte(Vector<const uc16> string,
3998 PretenureFlag pretenure) { 4003 PretenureFlag pretenure) {
3999 // Check if the string is an ASCII string. 4004 // Check if the string is an ASCII string.
4000 Object* result; 4005 Object* result;
4001 int length = string.length(); 4006 int length = string.length();
4002 const uc16* start = string.start(); 4007 const uc16* start = string.start();
4003 4008
4004 if (String::IsOneByte(start, length)) { 4009 if (String::IsOneByte(start, length)) {
4005 MaybeObject* maybe_result = AllocateRawOneByteString(length, pretenure); 4010 MaybeObject* maybe_result = AllocateRawOneByteString(length, pretenure);
4006 if (!maybe_result->ToObject(&result)) return maybe_result; 4011 if (!maybe_result->ToObject(&result) || result->IsException()) {
4012 return maybe_result;
4013 }
4007 CopyChars(SeqOneByteString::cast(result)->GetChars(), start, length); 4014 CopyChars(SeqOneByteString::cast(result)->GetChars(), start, length);
4008 } else { // It's not a one byte string. 4015 } else { // It's not a one byte string.
4009 MaybeObject* maybe_result = AllocateRawTwoByteString(length, pretenure); 4016 MaybeObject* maybe_result = AllocateRawTwoByteString(length, pretenure);
4010 if (!maybe_result->ToObject(&result)) return maybe_result; 4017 if (!maybe_result->ToObject(&result) || result->IsException()) {
4018 return maybe_result;
4019 }
4011 CopyChars(SeqTwoByteString::cast(result)->GetChars(), start, length); 4020 CopyChars(SeqTwoByteString::cast(result)->GetChars(), start, length);
4012 } 4021 }
4013 return result; 4022 return result;
4014 } 4023 }
4015 4024
4016 4025
4017 Map* Heap::InternalizedStringMapForString(String* string) { 4026 Map* Heap::InternalizedStringMapForString(String* string) {
4018 // If the string is in new space it cannot be used as internalized. 4027 // If the string is in new space it cannot be used as internalized.
4019 if (InNewSpace(string)) return NULL; 4028 if (InNewSpace(string)) return NULL;
4020 4029
(...skipping 2707 matching lines...) Expand 10 before | Expand all | Expand 10 after
6728 static_cast<int>(object_sizes_last_time_[index])); 6737 static_cast<int>(object_sizes_last_time_[index]));
6729 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6738 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6730 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6739 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6731 6740
6732 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6741 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6733 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6742 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6734 ClearObjectStats(); 6743 ClearObjectStats();
6735 } 6744 }
6736 6745
6737 } } // namespace v8::internal 6746 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/execution.cc ('k') | src/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698