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

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

Issue 131363008: A64: Synchronize with r15922. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | « test/cctest/cctest.status ('k') | test/cctest/test-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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "compilation-cache.h" 42 #include "compilation-cache.h"
43 #include "cpu-profiler.h" 43 #include "cpu-profiler.h"
44 #include "execution.h" 44 #include "execution.h"
45 #include "isolate.h" 45 #include "isolate.h"
46 #include "objects.h" 46 #include "objects.h"
47 #include "parser.h" 47 #include "parser.h"
48 #include "platform.h" 48 #include "platform.h"
49 #include "snapshot.h" 49 #include "snapshot.h"
50 #include "unicode-inl.h" 50 #include "unicode-inl.h"
51 #include "utils.h" 51 #include "utils.h"
52 #include "vm-state.h"
52 53
53 static const bool kLogThreading = false; 54 static const bool kLogThreading = false;
54 55
55 using ::v8::AccessorInfo; 56 using ::v8::AccessorInfo;
56 using ::v8::Arguments; 57 using ::v8::Arguments;
57 using ::v8::Context; 58 using ::v8::Context;
58 using ::v8::Extension; 59 using ::v8::Extension;
59 using ::v8::Function; 60 using ::v8::Function;
60 using ::v8::FunctionTemplate; 61 using ::v8::FunctionTemplate;
61 using ::v8::Handle; 62 using ::v8::Handle;
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 char* buf = i::NewArray<char>(buf_size); 614 char* buf = i::NewArray<char>(buf_size);
614 memset(buf, 'a', buf_size); 615 memset(buf, 'a', buf_size);
615 buf[buf_size - 1] = '\0'; 616 buf[buf_size - 1] = '\0';
616 Local<String> large_string = String::New(buf); 617 Local<String> large_string = String::New(buf);
617 i::DeleteArray(buf); 618 i::DeleteArray(buf);
618 // Large strings should be immediately accepted. 619 // Large strings should be immediately accepted.
619 CHECK(large_string->CanMakeExternal()); 620 CHECK(large_string->CanMakeExternal());
620 } 621 }
621 622
622 623
624 TEST(MakingExternalUnalignedAsciiString) {
625 LocalContext env;
626 v8::HandleScope scope(env->GetIsolate());
627
628 CompileRun("function cons(a, b) { return a + b; }"
629 "function slice(a) { return a.substring(1); }");
630 // Create a cons string that will land in old pointer space.
631 Local<String> cons = Local<String>::Cast(CompileRun(
632 "cons('abcdefghijklm', 'nopqrstuvwxyz');"));
633 // Create a sliced string that will land in old pointer space.
634 Local<String> slice = Local<String>::Cast(CompileRun(
635 "slice('abcdefghijklmnopqrstuvwxyz');"));
636
637 // Trigger GCs so that the newly allocated string moves to old gen.
638 SimulateFullSpace(HEAP->old_pointer_space());
639 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
640 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
641
642 // Turn into external string with unaligned resource data.
643 int dispose_count = 0;
644 const char* c_cons = "_abcdefghijklmnopqrstuvwxyz";
645 bool success = cons->MakeExternal(
646 new TestAsciiResource(i::StrDup(c_cons) + 1, &dispose_count));
647 CHECK(success);
648 const char* c_slice = "_bcdefghijklmnopqrstuvwxyz";
649 success = slice->MakeExternal(
650 new TestAsciiResource(i::StrDup(c_slice) + 1, &dispose_count));
651 CHECK(success);
652
653 // Trigger GCs and force evacuation.
654 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
655 HEAP->CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask);
656 }
657
658
623 THREADED_TEST(UsingExternalString) { 659 THREADED_TEST(UsingExternalString) {
624 i::Factory* factory = i::Isolate::Current()->factory(); 660 i::Factory* factory = i::Isolate::Current()->factory();
625 { 661 {
626 v8::HandleScope scope(v8::Isolate::GetCurrent()); 662 v8::HandleScope scope(v8::Isolate::GetCurrent());
627 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); 663 uint16_t* two_byte_string = AsciiToTwoByteString("test string");
628 Local<String> string = 664 Local<String> string =
629 String::NewExternal(new TestResource(two_byte_string)); 665 String::NewExternal(new TestResource(two_byte_string));
630 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); 666 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
631 // Trigger GCs so that the newly allocated string moves to old gen. 667 // Trigger GCs so that the newly allocated string moves to old gen.
632 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now 668 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 CHECK(!(*o)->IsTheHole() && !(*o)->IsUndefined()); 877 CHECK(!(*o)->IsTheHole() && !(*o)->IsUndefined());
842 rv.Set(v8::Handle<v8::Object>()); 878 rv.Set(v8::Handle<v8::Object>());
843 CHECK((*o)->IsTheHole() || (*o)->IsUndefined()); 879 CHECK((*o)->IsTheHole() || (*o)->IsUndefined());
844 CHECK_EQ(is_runtime, (*o)->IsTheHole()); 880 CHECK_EQ(is_runtime, (*o)->IsTheHole());
845 881
846 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(t.GetIsolate()); 882 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(t.GetIsolate());
847 // If CPU profiler is active check that when API callback is invoked 883 // If CPU profiler is active check that when API callback is invoked
848 // VMState is set to EXTERNAL. 884 // VMState is set to EXTERNAL.
849 if (isolate->cpu_profiler()->is_profiling()) { 885 if (isolate->cpu_profiler()->is_profiling()) {
850 CHECK_EQ(i::EXTERNAL, isolate->current_vm_state()); 886 CHECK_EQ(i::EXTERNAL, isolate->current_vm_state());
851 CHECK(isolate->external_callback()); 887 CHECK(isolate->external_callback_scope());
852 CHECK_EQ(callback, isolate->external_callback()); 888 CHECK_EQ(callback, isolate->external_callback_scope()->callback());
853 } 889 }
854 } 890 }
855 891
856 892
857 static void handle_callback_impl(const v8::FunctionCallbackInfo<Value>& info, 893 static void handle_callback_impl(const v8::FunctionCallbackInfo<Value>& info,
858 i::Address callback) { 894 i::Address callback) {
859 ApiTestFuzzer::Fuzz(); 895 ApiTestFuzzer::Fuzz();
860 CheckReturnValue(info, callback); 896 CheckReturnValue(info, callback);
861 info.GetReturnValue().Set(v8_str("bad value")); 897 info.GetReturnValue().Set(v8_str("bad value"));
862 info.GetReturnValue().Set(v8_num(102)); 898 info.GetReturnValue().Set(v8_num(102));
(...skipping 19033 matching lines...) Expand 10 before | Expand all | Expand 10 after
19896 CheckCorrectThrow("%HasProperty(other, 'x')"); 19932 CheckCorrectThrow("%HasProperty(other, 'x')");
19897 CheckCorrectThrow("%HasElement(other, 1)"); 19933 CheckCorrectThrow("%HasElement(other, 1)");
19898 CheckCorrectThrow("%IsPropertyEnumerable(other, 'x')"); 19934 CheckCorrectThrow("%IsPropertyEnumerable(other, 'x')");
19899 CheckCorrectThrow("%GetPropertyNames(other)"); 19935 CheckCorrectThrow("%GetPropertyNames(other)");
19900 CheckCorrectThrow("%GetLocalPropertyNames(other, true)"); 19936 CheckCorrectThrow("%GetLocalPropertyNames(other, true)");
19901 CheckCorrectThrow("%DefineOrRedefineAccessorProperty(" 19937 CheckCorrectThrow("%DefineOrRedefineAccessorProperty("
19902 "other, 'x', null, null, 1)"); 19938 "other, 'x', null, null, 1)");
19903 } 19939 }
19904 19940
19905 #endif // WIN32 19941 #endif // WIN32
OLDNEW
« no previous file with comments | « test/cctest/cctest.status ('k') | test/cctest/test-assembler-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698