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

Side by Side Diff: test/cctest/test-api.cc

Issue 306473004: Reland 21502 - "Move OS::MemCopy and OS::MemMove out of platform to utils" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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/x87/deoptimizer-x87.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 14894 matching lines...) Expand 10 before | Expand all | Expand 10 after
14905 HandleScope handle_scope(isolate); 14905 HandleScope handle_scope(isolate);
14906 14906
14907 i::FLAG_min_preparse_length = 0; 14907 i::FLAG_min_preparse_length = 0;
14908 const char* script = "function foo(a) { return a+1; }"; 14908 const char* script = "function foo(a) { return a+1; }";
14909 v8::ScriptCompiler::Source source(v8_str(script)); 14909 v8::ScriptCompiler::Source source(v8_str(script));
14910 v8::ScriptCompiler::Compile(isolate, &source, 14910 v8::ScriptCompiler::Compile(isolate, &source,
14911 v8::ScriptCompiler::kProduceDataToCache); 14911 v8::ScriptCompiler::kProduceDataToCache);
14912 // Serialize. 14912 // Serialize.
14913 const v8::ScriptCompiler::CachedData* cd = source.GetCachedData(); 14913 const v8::ScriptCompiler::CachedData* cd = source.GetCachedData();
14914 char* serialized_data = i::NewArray<char>(cd->length); 14914 char* serialized_data = i::NewArray<char>(cd->length);
14915 i::OS::MemCopy(serialized_data, cd->data, cd->length); 14915 i::MemCopy(serialized_data, cd->data, cd->length);
14916 14916
14917 // Deserialize. 14917 // Deserialize.
14918 i::ScriptData* deserialized = i::ScriptData::New(serialized_data, cd->length); 14918 i::ScriptData* deserialized = i::ScriptData::New(serialized_data, cd->length);
14919 14919
14920 // Verify that the original is the same as the deserialized. 14920 // Verify that the original is the same as the deserialized.
14921 CHECK_EQ(cd->length, deserialized->Length()); 14921 CHECK_EQ(cd->length, deserialized->Length());
14922 CHECK_EQ(0, memcmp(cd->data, deserialized->Data(), cd->length)); 14922 CHECK_EQ(0, memcmp(cd->data, deserialized->Data(), cd->length));
14923 14923
14924 delete deserialized; 14924 delete deserialized;
14925 i::DeleteArray(serialized_data); 14925 i::DeleteArray(serialized_data);
(...skipping 3159 matching lines...) Expand 10 before | Expand all | Expand 10 after
18085 CcTest::i_isolate()->compilation_cache()->Clear(); 18085 CcTest::i_isolate()->compilation_cache()->Clear();
18086 CcTest::heap()->CollectAllAvailableGarbage(); 18086 CcTest::heap()->CollectAllAvailableGarbage();
18087 18087
18088 // Ring has been destroyed. Free Peoples of Middle-earth Rejoice. 18088 // Ring has been destroyed. Free Peoples of Middle-earth Rejoice.
18089 CHECK_EQ(1, destroyed); 18089 CHECK_EQ(1, destroyed);
18090 } 18090 }
18091 18091
18092 18092
18093 static double DoubleFromBits(uint64_t value) { 18093 static double DoubleFromBits(uint64_t value) {
18094 double target; 18094 double target;
18095 i::OS::MemCopy(&target, &value, sizeof(target)); 18095 i::MemCopy(&target, &value, sizeof(target));
18096 return target; 18096 return target;
18097 } 18097 }
18098 18098
18099 18099
18100 static uint64_t DoubleToBits(double value) { 18100 static uint64_t DoubleToBits(double value) {
18101 uint64_t target; 18101 uint64_t target;
18102 i::OS::MemCopy(&target, &value, sizeof(target)); 18102 i::MemCopy(&target, &value, sizeof(target));
18103 return target; 18103 return target;
18104 } 18104 }
18105 18105
18106 18106
18107 static double DoubleToDateTime(double input) { 18107 static double DoubleToDateTime(double input) {
18108 double date_limit = 864e13; 18108 double date_limit = 864e13;
18109 if (std::isnan(input) || input < -date_limit || input > date_limit) { 18109 if (std::isnan(input) || input < -date_limit || input > date_limit) {
18110 return i::OS::nan_value(); 18110 return i::OS::nan_value();
18111 } 18111 }
18112 return (input < 0) ? -(std::floor(-input)) : std::floor(input); 18112 return (input < 0) ? -(std::floor(-input)) : std::floor(input);
(...skipping 4528 matching lines...) Expand 10 before | Expand all | Expand 10 after
22641 Local<Script> script = v8::ScriptCompiler::Compile( 22641 Local<Script> script = v8::ScriptCompiler::Compile(
22642 isolate, &script_source); 22642 isolate, &script_source);
22643 Local<Value> script_name = script->GetUnboundScript()->GetScriptName(); 22643 Local<Value> script_name = script->GetUnboundScript()->GetScriptName();
22644 CHECK(!script_name.IsEmpty()); 22644 CHECK(!script_name.IsEmpty());
22645 CHECK(script_name->IsString()); 22645 CHECK(script_name->IsString());
22646 String::Utf8Value utf8_name(script_name); 22646 String::Utf8Value utf8_name(script_name);
22647 CHECK_EQ(url, *utf8_name); 22647 CHECK_EQ(url, *utf8_name);
22648 int line_number = script->GetUnboundScript()->GetLineNumber(0); 22648 int line_number = script->GetUnboundScript()->GetLineNumber(0);
22649 CHECK_EQ(13, line_number); 22649 CHECK_EQ(13, line_number);
22650 } 22650 }
OLDNEW
« no previous file with comments | « src/x87/deoptimizer-x87.cc ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698