OLD | NEW |
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 2664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2675 template <typename T> | 2675 template <typename T> |
2676 static void CheckInternalFieldsAreZero(v8::Handle<T> value) { | 2676 static void CheckInternalFieldsAreZero(v8::Handle<T> value) { |
2677 CHECK_EQ(T::kInternalFieldCount, value->InternalFieldCount()); | 2677 CHECK_EQ(T::kInternalFieldCount, value->InternalFieldCount()); |
2678 for (int i = 0; i < value->InternalFieldCount(); i++) { | 2678 for (int i = 0; i < value->InternalFieldCount(); i++) { |
2679 CHECK_EQ(0, value->GetInternalField(i)->Int32Value()); | 2679 CHECK_EQ(0, value->GetInternalField(i)->Int32Value()); |
2680 } | 2680 } |
2681 } | 2681 } |
2682 | 2682 |
2683 | 2683 |
2684 THREADED_TEST(ArrayBuffer_ApiInternalToExternal) { | 2684 THREADED_TEST(ArrayBuffer_ApiInternalToExternal) { |
2685 i::FLAG_harmony_array_buffer = true; | |
2686 i::FLAG_harmony_typed_arrays = true; | |
2687 | |
2688 LocalContext env; | 2685 LocalContext env; |
2689 v8::Isolate* isolate = env->GetIsolate(); | 2686 v8::Isolate* isolate = env->GetIsolate(); |
2690 v8::HandleScope handle_scope(isolate); | 2687 v8::HandleScope handle_scope(isolate); |
2691 | 2688 |
2692 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(1024); | 2689 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(1024); |
2693 CheckInternalFieldsAreZero(ab); | 2690 CheckInternalFieldsAreZero(ab); |
2694 CHECK_EQ(1024, static_cast<int>(ab->ByteLength())); | 2691 CHECK_EQ(1024, static_cast<int>(ab->ByteLength())); |
2695 CHECK(!ab->IsExternal()); | 2692 CHECK(!ab->IsExternal()); |
2696 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 2693 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
2697 | 2694 |
(...skipping 16 matching lines...) Expand all Loading... |
2714 CHECK_EQ(0xFF, data[0]); | 2711 CHECK_EQ(0xFF, data[0]); |
2715 CHECK_EQ(0xAA, data[1]); | 2712 CHECK_EQ(0xAA, data[1]); |
2716 data[0] = 0xCC; | 2713 data[0] = 0xCC; |
2717 data[1] = 0x11; | 2714 data[1] = 0x11; |
2718 result = CompileRun("u8[0] + u8[1]"); | 2715 result = CompileRun("u8[0] + u8[1]"); |
2719 CHECK_EQ(0xDD, result->Int32Value()); | 2716 CHECK_EQ(0xDD, result->Int32Value()); |
2720 } | 2717 } |
2721 | 2718 |
2722 | 2719 |
2723 THREADED_TEST(ArrayBuffer_JSInternalToExternal) { | 2720 THREADED_TEST(ArrayBuffer_JSInternalToExternal) { |
2724 i::FLAG_harmony_array_buffer = true; | |
2725 i::FLAG_harmony_typed_arrays = true; | |
2726 | |
2727 LocalContext env; | 2721 LocalContext env; |
2728 v8::Isolate* isolate = env->GetIsolate(); | 2722 v8::Isolate* isolate = env->GetIsolate(); |
2729 v8::HandleScope handle_scope(isolate); | 2723 v8::HandleScope handle_scope(isolate); |
2730 | 2724 |
2731 | 2725 |
2732 v8::Local<v8::Value> result = | 2726 v8::Local<v8::Value> result = |
2733 CompileRun("var ab1 = new ArrayBuffer(2);" | 2727 CompileRun("var ab1 = new ArrayBuffer(2);" |
2734 "var u8_a = new Uint8Array(ab1);" | 2728 "var u8_a = new Uint8Array(ab1);" |
2735 "u8_a[0] = 0xAA;" | 2729 "u8_a[0] = 0xAA;" |
2736 "u8_a[1] = 0xFF; u8_a.buffer"); | 2730 "u8_a[1] = 0xFF; u8_a.buffer"); |
(...skipping 22 matching lines...) Expand all Loading... |
2759 CHECK_EQ(0xBB, ab1_data[0]); | 2753 CHECK_EQ(0xBB, ab1_data[0]); |
2760 CHECK_EQ(0xFF, ab1_data[1]); | 2754 CHECK_EQ(0xFF, ab1_data[1]); |
2761 ab1_data[0] = 0xCC; | 2755 ab1_data[0] = 0xCC; |
2762 ab1_data[1] = 0x11; | 2756 ab1_data[1] = 0x11; |
2763 result = CompileRun("u8_a[0] + u8_a[1]"); | 2757 result = CompileRun("u8_a[0] + u8_a[1]"); |
2764 CHECK_EQ(0xDD, result->Int32Value()); | 2758 CHECK_EQ(0xDD, result->Int32Value()); |
2765 } | 2759 } |
2766 | 2760 |
2767 | 2761 |
2768 THREADED_TEST(ArrayBuffer_External) { | 2762 THREADED_TEST(ArrayBuffer_External) { |
2769 i::FLAG_harmony_array_buffer = true; | |
2770 i::FLAG_harmony_typed_arrays = true; | |
2771 | |
2772 LocalContext env; | 2763 LocalContext env; |
2773 v8::Isolate* isolate = env->GetIsolate(); | 2764 v8::Isolate* isolate = env->GetIsolate(); |
2774 v8::HandleScope handle_scope(isolate); | 2765 v8::HandleScope handle_scope(isolate); |
2775 | 2766 |
2776 i::ScopedVector<uint8_t> my_data(100); | 2767 i::ScopedVector<uint8_t> my_data(100); |
2777 memset(my_data.start(), 0, 100); | 2768 memset(my_data.start(), 0, 100); |
2778 Local<v8::ArrayBuffer> ab3 = v8::ArrayBuffer::New(my_data.start(), 100); | 2769 Local<v8::ArrayBuffer> ab3 = v8::ArrayBuffer::New(my_data.start(), 100); |
2779 CheckInternalFieldsAreZero(ab3); | 2770 CheckInternalFieldsAreZero(ab3); |
2780 CHECK_EQ(100, static_cast<int>(ab3->ByteLength())); | 2771 CHECK_EQ(100, static_cast<int>(ab3->ByteLength())); |
2781 CHECK(ab3->IsExternal()); | 2772 CHECK(ab3->IsExternal()); |
(...skipping 10169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12951 | 12942 |
12952 isolate->Dispose(); | 12943 isolate->Dispose(); |
12953 } | 12944 } |
12954 | 12945 |
12955 | 12946 |
12956 TEST(SetFunctionEntryHook) { | 12947 TEST(SetFunctionEntryHook) { |
12957 // FunctionEntryHook does not work well with experimental natives. | 12948 // FunctionEntryHook does not work well with experimental natives. |
12958 // Experimental natives are compiled during snapshot deserialization. | 12949 // Experimental natives are compiled during snapshot deserialization. |
12959 // This test breaks because InstallGetter (function from snapshot that | 12950 // This test breaks because InstallGetter (function from snapshot that |
12960 // only gets called from experimental natives) is compiled with entry hooks. | 12951 // only gets called from experimental natives) is compiled with entry hooks. |
12961 i::FLAG_harmony_typed_arrays = false; | |
12962 i::FLAG_harmony_array_buffer = false; | |
12963 | |
12964 i::FLAG_allow_natives_syntax = true; | 12952 i::FLAG_allow_natives_syntax = true; |
12965 i::FLAG_use_inlining = false; | 12953 i::FLAG_use_inlining = false; |
12966 | 12954 |
12967 SetFunctionEntryHookTest test; | 12955 SetFunctionEntryHookTest test; |
12968 test.RunTest(); | 12956 test.RunTest(); |
12969 } | 12957 } |
12970 | 12958 |
12971 | 12959 |
12972 static i::HashMap* code_map = NULL; | 12960 static i::HashMap* code_map = NULL; |
12973 static i::HashMap* jitcode_line_info = NULL; | 12961 static i::HashMap* jitcode_line_info = NULL; |
(...skipping 3176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16150 v8::DataView::New(ab, 2, kSize); | 16138 v8::DataView::New(ab, 2, kSize); |
16151 CheckInternalFieldsAreZero<v8::ArrayBufferView>(dv); | 16139 CheckInternalFieldsAreZero<v8::ArrayBufferView>(dv); |
16152 CHECK_EQ(2, static_cast<int>(dv->ByteOffset())); | 16140 CHECK_EQ(2, static_cast<int>(dv->ByteOffset())); |
16153 CHECK_EQ(kSize, static_cast<int>(dv->ByteLength())); | 16141 CHECK_EQ(kSize, static_cast<int>(dv->ByteLength())); |
16154 CHECK_EQ(ab, dv->Buffer()); | 16142 CHECK_EQ(ab, dv->Buffer()); |
16155 } | 16143 } |
16156 | 16144 |
16157 | 16145 |
16158 #define IS_ARRAY_BUFFER_VIEW_TEST(View) \ | 16146 #define IS_ARRAY_BUFFER_VIEW_TEST(View) \ |
16159 THREADED_TEST(Is##View) { \ | 16147 THREADED_TEST(Is##View) { \ |
16160 i::FLAG_harmony_array_buffer = true; \ | |
16161 i::FLAG_harmony_typed_arrays = true; \ | |
16162 LocalContext env; \ | 16148 LocalContext env; \ |
16163 v8::Isolate* isolate = env->GetIsolate(); \ | 16149 v8::Isolate* isolate = env->GetIsolate(); \ |
16164 v8::HandleScope handle_scope(isolate); \ | 16150 v8::HandleScope handle_scope(isolate); \ |
16165 \ | 16151 \ |
16166 Handle<Value> result = CompileRun( \ | 16152 Handle<Value> result = CompileRun( \ |
16167 "var ab = new ArrayBuffer(128);" \ | 16153 "var ab = new ArrayBuffer(128);" \ |
16168 "new " #View "(ab)"); \ | 16154 "new " #View "(ab)"); \ |
16169 CHECK(result->IsArrayBufferView()); \ | 16155 CHECK(result->IsArrayBufferView()); \ |
16170 CHECK(result->Is##View()); \ | 16156 CHECK(result->Is##View()); \ |
16171 CheckInternalFieldsAreZero<v8::ArrayBufferView>(result.As<v8::View>()); \ | 16157 CheckInternalFieldsAreZero<v8::ArrayBufferView>(result.As<v8::View>()); \ |
(...skipping 3999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20171 CheckCorrectThrow("%GetLocalPropertyNames(other, true)"); | 20157 CheckCorrectThrow("%GetLocalPropertyNames(other, true)"); |
20172 CheckCorrectThrow("%DefineOrRedefineAccessorProperty(" | 20158 CheckCorrectThrow("%DefineOrRedefineAccessorProperty(" |
20173 "other, 'x', null, null, 1)"); | 20159 "other, 'x', null, null, 1)"); |
20174 | 20160 |
20175 // Reset the failed access check callback so it does not influence | 20161 // Reset the failed access check callback so it does not influence |
20176 // the other tests. | 20162 // the other tests. |
20177 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); | 20163 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); |
20178 } | 20164 } |
20179 | 20165 |
20180 #endif // WIN32 | 20166 #endif // WIN32 |
OLD | NEW |