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

Side by Side Diff: src/api.cc

Issue 13932006: Replace OS::MemCopy with OS::MemMove (just as fast but more flexible). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 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/allocation.cc ('k') | src/arm/assembler-arm.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 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 } 1679 }
1680 1680
1681 // Copy the data to ensure it is properly aligned. 1681 // Copy the data to ensure it is properly aligned.
1682 int deserialized_data_length = length / sizeof(unsigned); 1682 int deserialized_data_length = length / sizeof(unsigned);
1683 // If aligned, don't create a copy of the data. 1683 // If aligned, don't create a copy of the data.
1684 if (reinterpret_cast<intptr_t>(data) % sizeof(unsigned) == 0) { 1684 if (reinterpret_cast<intptr_t>(data) % sizeof(unsigned) == 0) {
1685 return new i::ScriptDataImpl(data, length); 1685 return new i::ScriptDataImpl(data, length);
1686 } 1686 }
1687 // Copy the data to align it. 1687 // Copy the data to align it.
1688 unsigned* deserialized_data = i::NewArray<unsigned>(deserialized_data_length); 1688 unsigned* deserialized_data = i::NewArray<unsigned>(deserialized_data_length);
1689 i::OS::MemCopy(deserialized_data, data, length); 1689 i::CopyBytes(reinterpret_cast<char*>(deserialized_data),
1690 data, static_cast<size_t>(length));
1690 1691
1691 return new i::ScriptDataImpl( 1692 return new i::ScriptDataImpl(
1692 i::Vector<unsigned>(deserialized_data, deserialized_data_length)); 1693 i::Vector<unsigned>(deserialized_data, deserialized_data_length));
1693 } 1694 }
1694 1695
1695 1696
1696 // --- S c r i p t --- 1697 // --- S c r i p t ---
1697 1698
1698 1699
1699 Local<Script> Script::New(v8::Handle<String> source, 1700 Local<Script> Script::New(v8::Handle<String> source,
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after
3243 3244
3244 int prefix_len = i::StrLength(prefix); 3245 int prefix_len = i::StrLength(prefix);
3245 int str_len = str->Length(); 3246 int str_len = str->Length();
3246 int postfix_len = i::StrLength(postfix); 3247 int postfix_len = i::StrLength(postfix);
3247 3248
3248 int buf_len = prefix_len + str_len + postfix_len; 3249 int buf_len = prefix_len + str_len + postfix_len;
3249 i::ScopedVector<char> buf(buf_len); 3250 i::ScopedVector<char> buf(buf_len);
3250 3251
3251 // Write prefix. 3252 // Write prefix.
3252 char* ptr = buf.start(); 3253 char* ptr = buf.start();
3253 memcpy(ptr, prefix, prefix_len * v8::internal::kCharSize); 3254 i::OS::MemCopy(ptr, prefix, prefix_len * v8::internal::kCharSize);
3254 ptr += prefix_len; 3255 ptr += prefix_len;
3255 3256
3256 // Write real content. 3257 // Write real content.
3257 str->WriteAscii(ptr, 0, str_len); 3258 str->WriteAscii(ptr, 0, str_len);
3258 ptr += str_len; 3259 ptr += str_len;
3259 3260
3260 // Write postfix. 3261 // Write postfix.
3261 memcpy(ptr, postfix, postfix_len * v8::internal::kCharSize); 3262 i::OS::MemCopy(ptr, postfix, postfix_len * v8::internal::kCharSize);
3262 3263
3263 // Copy the buffer into a heap-allocated string and return it. 3264 // Copy the buffer into a heap-allocated string and return it.
3264 Local<String> result = v8::String::New(buf.start(), buf_len); 3265 Local<String> result = v8::String::New(buf.start(), buf_len);
3265 return result; 3266 return result;
3266 } 3267 }
3267 } 3268 }
3268 } 3269 }
3269 3270
3270 3271
3271 Local<Value> v8::Object::GetConstructor() { 3272 Local<Value> v8::Object::GetConstructor() {
(...skipping 3960 matching lines...) Expand 10 before | Expand all | Expand 10 after
7232 7233
7233 void HandleScopeImplementer::FreeThreadResources() { 7234 void HandleScopeImplementer::FreeThreadResources() {
7234 Free(); 7235 Free();
7235 } 7236 }
7236 7237
7237 7238
7238 char* HandleScopeImplementer::ArchiveThread(char* storage) { 7239 char* HandleScopeImplementer::ArchiveThread(char* storage) {
7239 v8::ImplementationUtilities::HandleScopeData* current = 7240 v8::ImplementationUtilities::HandleScopeData* current =
7240 isolate_->handle_scope_data(); 7241 isolate_->handle_scope_data();
7241 handle_scope_data_ = *current; 7242 handle_scope_data_ = *current;
7242 memcpy(storage, this, sizeof(*this)); 7243 OS::MemCopy(storage, this, sizeof(*this));
7243 7244
7244 ResetAfterArchive(); 7245 ResetAfterArchive();
7245 current->Initialize(); 7246 current->Initialize();
7246 7247
7247 return storage + ArchiveSpacePerThread(); 7248 return storage + ArchiveSpacePerThread();
7248 } 7249 }
7249 7250
7250 7251
7251 int HandleScopeImplementer::ArchiveSpacePerThread() { 7252 int HandleScopeImplementer::ArchiveSpacePerThread() {
7252 return sizeof(HandleScopeImplementer); 7253 return sizeof(HandleScopeImplementer);
7253 } 7254 }
7254 7255
7255 7256
7256 char* HandleScopeImplementer::RestoreThread(char* storage) { 7257 char* HandleScopeImplementer::RestoreThread(char* storage) {
7257 memcpy(this, storage, sizeof(*this)); 7258 OS::MemCopy(this, storage, sizeof(*this));
7258 *isolate_->handle_scope_data() = handle_scope_data_; 7259 *isolate_->handle_scope_data() = handle_scope_data_;
7259 return storage + ArchiveSpacePerThread(); 7260 return storage + ArchiveSpacePerThread();
7260 } 7261 }
7261 7262
7262 7263
7263 void HandleScopeImplementer::IterateThis(ObjectVisitor* v) { 7264 void HandleScopeImplementer::IterateThis(ObjectVisitor* v) {
7264 #ifdef DEBUG 7265 #ifdef DEBUG
7265 bool found_block_before_deferred = false; 7266 bool found_block_before_deferred = false;
7266 #endif 7267 #endif
7267 // Iterate over all handles in the blocks except for the last. 7268 // Iterate over all handles in the blocks except for the last.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
7366 7367
7367 v->VisitPointers(blocks_.first(), first_block_limit_); 7368 v->VisitPointers(blocks_.first(), first_block_limit_);
7368 7369
7369 for (int i = 1; i < blocks_.length(); i++) { 7370 for (int i = 1; i < blocks_.length(); i++) {
7370 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 7371 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
7371 } 7372 }
7372 } 7373 }
7373 7374
7374 7375
7375 } } // namespace v8::internal 7376 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/allocation.cc ('k') | src/arm/assembler-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698