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

Side by Side Diff: test/cctest/test-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/x64/lithium-codegen-x64.cc ('k') | test/cctest/test-compiler.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 12777 matching lines...) Expand 10 before | Expand all | Expand 10 after
12788 // Tests that ScriptData can be serialized and deserialized. 12788 // Tests that ScriptData can be serialized and deserialized.
12789 TEST(PreCompileSerialization) { 12789 TEST(PreCompileSerialization) {
12790 v8::V8::Initialize(); 12790 v8::V8::Initialize();
12791 const char* script = "function foo(a) { return a+1; }"; 12791 const char* script = "function foo(a) { return a+1; }";
12792 v8::ScriptData* sd = 12792 v8::ScriptData* sd =
12793 v8::ScriptData::PreCompile(script, i::StrLength(script)); 12793 v8::ScriptData::PreCompile(script, i::StrLength(script));
12794 12794
12795 // Serialize. 12795 // Serialize.
12796 int serialized_data_length = sd->Length(); 12796 int serialized_data_length = sd->Length();
12797 char* serialized_data = i::NewArray<char>(serialized_data_length); 12797 char* serialized_data = i::NewArray<char>(serialized_data_length);
12798 memcpy(serialized_data, sd->Data(), serialized_data_length); 12798 i::OS::MemCopy(serialized_data, sd->Data(), serialized_data_length);
12799 12799
12800 // Deserialize. 12800 // Deserialize.
12801 v8::ScriptData* deserialized_sd = 12801 v8::ScriptData* deserialized_sd =
12802 v8::ScriptData::New(serialized_data, serialized_data_length); 12802 v8::ScriptData::New(serialized_data, serialized_data_length);
12803 12803
12804 // Verify that the original is the same as the deserialized. 12804 // Verify that the original is the same as the deserialized.
12805 CHECK_EQ(sd->Length(), deserialized_sd->Length()); 12805 CHECK_EQ(sd->Length(), deserialized_sd->Length());
12806 CHECK_EQ(0, memcmp(sd->Data(), deserialized_sd->Data(), sd->Length())); 12806 CHECK_EQ(0, memcmp(sd->Data(), deserialized_sd->Data(), sd->Length()));
12807 CHECK_EQ(sd->HasError(), deserialized_sd->HasError()); 12807 CHECK_EQ(sd->HasError(), deserialized_sd->HasError());
12808 12808
(...skipping 2919 matching lines...) Expand 10 before | Expand all | Expand 10 after
15728 CHECK(string3->IsExternal()); 15728 CHECK(string3->IsExternal());
15729 15729
15730 VisitorImpl visitor(resource); 15730 VisitorImpl visitor(resource);
15731 v8::V8::VisitExternalResources(&visitor); 15731 v8::V8::VisitExternalResources(&visitor);
15732 visitor.CheckVisitedResources(); 15732 visitor.CheckVisitedResources();
15733 } 15733 }
15734 15734
15735 15735
15736 static double DoubleFromBits(uint64_t value) { 15736 static double DoubleFromBits(uint64_t value) {
15737 double target; 15737 double target;
15738 memcpy(&target, &value, sizeof(target)); 15738 i::OS::MemCopy(&target, &value, sizeof(target));
15739 return target; 15739 return target;
15740 } 15740 }
15741 15741
15742 15742
15743 static uint64_t DoubleToBits(double value) { 15743 static uint64_t DoubleToBits(double value) {
15744 uint64_t target; 15744 uint64_t target;
15745 memcpy(&target, &value, sizeof(target)); 15745 i::OS::MemCopy(&target, &value, sizeof(target));
15746 return target; 15746 return target;
15747 } 15747 }
15748 15748
15749 15749
15750 static double DoubleToDateTime(double input) { 15750 static double DoubleToDateTime(double input) {
15751 double date_limit = 864e13; 15751 double date_limit = 864e13;
15752 if (IsNaN(input) || input < -date_limit || input > date_limit) { 15752 if (IsNaN(input) || input < -date_limit || input > date_limit) {
15753 return i::OS::nan_value(); 15753 return i::OS::nan_value();
15754 } 15754 }
15755 return (input < 0) ? -(floor(-input)) : floor(input); 15755 return (input < 0) ? -(floor(-input)) : floor(input);
(...skipping 2942 matching lines...) Expand 10 before | Expand all | Expand 10 after
18698 i::Semaphore* sem_; 18698 i::Semaphore* sem_;
18699 volatile int sem_value_; 18699 volatile int sem_value_;
18700 }; 18700 };
18701 18701
18702 18702
18703 THREADED_TEST(SemaphoreInterruption) { 18703 THREADED_TEST(SemaphoreInterruption) {
18704 ThreadInterruptTest().RunTest(); 18704 ThreadInterruptTest().RunTest();
18705 } 18705 }
18706 18706
18707 #endif // WIN32 18707 #endif // WIN32
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.cc ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698