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

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

Issue 1413463006: Map v8::Object to v8::internal::JSReceiver (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 1 month 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
« no previous file with comments | « test/cctest/compiler/function-tester.h ('k') | test/cctest/test-api-interceptors.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 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { 1921 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
1922 info.GetReturnValue().Set(info.GetIsolate()->ThrowException(name)); 1922 info.GetReturnValue().Set(info.GetIsolate()->ThrowException(name));
1923 } 1923 }
1924 1924
1925 1925
1926 THREADED_TEST(ExecutableAccessorIsPreservedOnAttributeChange) { 1926 THREADED_TEST(ExecutableAccessorIsPreservedOnAttributeChange) {
1927 v8::Isolate* isolate = CcTest::isolate(); 1927 v8::Isolate* isolate = CcTest::isolate();
1928 v8::HandleScope scope(isolate); 1928 v8::HandleScope scope(isolate);
1929 LocalContext env; 1929 LocalContext env;
1930 v8::Local<v8::Value> res = CompileRun("var a = []; a;"); 1930 v8::Local<v8::Value> res = CompileRun("var a = []; a;");
1931 i::Handle<i::JSObject> a(v8::Utils::OpenHandle(v8::Object::Cast(*res))); 1931 i::Handle<i::JSReceiver> a(v8::Utils::OpenHandle(v8::Object::Cast(*res)));
1932 CHECK(a->map()->instance_descriptors()->IsFixedArray()); 1932 CHECK(a->map()->instance_descriptors()->IsFixedArray());
1933 CHECK_GT(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0); 1933 CHECK_GT(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0);
1934 CompileRun("Object.defineProperty(a, 'length', { writable: false });"); 1934 CompileRun("Object.defineProperty(a, 'length', { writable: false });");
1935 CHECK_EQ(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0); 1935 CHECK_EQ(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0);
1936 // But we should still have an ExecutableAccessorInfo. 1936 // But we should still have an ExecutableAccessorInfo.
1937 i::Handle<i::String> name(v8::Utils::OpenHandle(*v8_str("length"))); 1937 i::Handle<i::String> name(v8::Utils::OpenHandle(*v8_str("length")));
1938 i::LookupIterator it(a, name, i::LookupIterator::OWN_SKIP_INTERCEPTOR); 1938 i::LookupIterator it(a, name, i::LookupIterator::OWN_SKIP_INTERCEPTOR);
1939 CHECK_EQ(i::LookupIterator::ACCESSOR, it.state()); 1939 CHECK_EQ(i::LookupIterator::ACCESSOR, it.state());
1940 CHECK(it.GetAccessors()->IsExecutableAccessorInfo()); 1940 CHECK(it.GetAccessors()->IsExecutableAccessorInfo());
1941 } 1941 }
(...skipping 7781 matching lines...) Expand 10 before | Expand all | Expand 10 after
9723 9723
9724 THREADED_TEST(Constructor) { 9724 THREADED_TEST(Constructor) {
9725 LocalContext context; 9725 LocalContext context;
9726 v8::Isolate* isolate = context->GetIsolate(); 9726 v8::Isolate* isolate = context->GetIsolate();
9727 v8::HandleScope handle_scope(isolate); 9727 v8::HandleScope handle_scope(isolate);
9728 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); 9728 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
9729 templ->SetClassName(v8_str("Fun")); 9729 templ->SetClassName(v8_str("Fun"));
9730 Local<Function> cons = templ->GetFunction(); 9730 Local<Function> cons = templ->GetFunction();
9731 context->Global()->Set(v8_str("Fun"), cons); 9731 context->Global()->Set(v8_str("Fun"), cons);
9732 Local<v8::Object> inst = cons->NewInstance(); 9732 Local<v8::Object> inst = cons->NewInstance();
9733 i::Handle<i::JSObject> obj(v8::Utils::OpenHandle(*inst)); 9733 i::Handle<i::JSReceiver> obj(v8::Utils::OpenHandle(*inst));
9734 CHECK(obj->IsJSObject()); 9734 CHECK(obj->IsJSObject());
9735 Local<Value> value = CompileRun("(new Fun()).constructor === Fun"); 9735 Local<Value> value = CompileRun("(new Fun()).constructor === Fun");
9736 CHECK(value->BooleanValue()); 9736 CHECK(value->BooleanValue());
9737 } 9737 }
9738 9738
9739 9739
9740 static void ConstructorCallback( 9740 static void ConstructorCallback(
9741 const v8::FunctionCallbackInfo<v8::Value>& args) { 9741 const v8::FunctionCallbackInfo<v8::Value>& args) {
9742 ApiTestFuzzer::Fuzz(); 9742 ApiTestFuzzer::Fuzz();
9743 Local<Object> This; 9743 Local<Object> This;
(...skipping 3990 matching lines...) Expand 10 before | Expand all | Expand 10 after
13734 CHECK_EQ(expected, i::Smi::cast(element)->value()); 13734 CHECK_EQ(expected, i::Smi::cast(element)->value());
13735 } 13735 }
13736 13736
13737 13737
13738 template <class ExternalArrayClass, class ElementType> 13738 template <class ExternalArrayClass, class ElementType>
13739 static void ObjectWithExternalArrayTestHelper(Handle<Context> context, 13739 static void ObjectWithExternalArrayTestHelper(Handle<Context> context,
13740 v8::Handle<Object> obj, 13740 v8::Handle<Object> obj,
13741 int element_count, 13741 int element_count,
13742 i::ExternalArrayType array_type, 13742 i::ExternalArrayType array_type,
13743 int64_t low, int64_t high) { 13743 int64_t low, int64_t high) {
13744 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); 13744 i::Handle<i::JSReceiver> jsobj = v8::Utils::OpenHandle(*obj);
13745 i::Isolate* isolate = jsobj->GetIsolate(); 13745 i::Isolate* isolate = jsobj->GetIsolate();
13746 obj->Set(v8_str("field"), 13746 obj->Set(v8_str("field"),
13747 v8::Int32::New(reinterpret_cast<v8::Isolate*>(isolate), 1503)); 13747 v8::Int32::New(reinterpret_cast<v8::Isolate*>(isolate), 1503));
13748 context->Global()->Set(v8_str("ext_array"), obj); 13748 context->Global()->Set(v8_str("ext_array"), obj);
13749 v8::Handle<v8::Value> result = CompileRun("ext_array.field"); 13749 v8::Handle<v8::Value> result = CompileRun("ext_array.field");
13750 CHECK_EQ(1503, result->Int32Value()); 13750 CHECK_EQ(1503, result->Int32Value());
13751 result = CompileRun("ext_array[1]"); 13751 result = CompileRun("ext_array[1]");
13752 CHECK_EQ(1, result->Int32Value()); 13752 CHECK_EQ(1, result->Int32Value());
13753 13753
13754 // Check assigned smis 13754 // Check assigned smis
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
13964 " (ext_array[5] == expected_results[i]);" 13964 " (ext_array[5] == expected_results[i]);"
13965 "}" 13965 "}"
13966 "all_passed;", 13966 "all_passed;",
13967 (is_unsigned ? 13967 (is_unsigned ?
13968 unsigned_data : 13968 unsigned_data :
13969 (is_pixel_data ? pixel_data : signed_data))); 13969 (is_pixel_data ? pixel_data : signed_data)));
13970 result = CompileRun(test_buf.start()); 13970 result = CompileRun(test_buf.start());
13971 CHECK_EQ(true, result->BooleanValue()); 13971 CHECK_EQ(true, result->BooleanValue());
13972 } 13972 }
13973 13973
13974 i::Handle<ExternalArrayClass> array( 13974 i::Handle<ExternalArrayClass> array(ExternalArrayClass::cast(
13975 ExternalArrayClass::cast(jsobj->elements())); 13975 i::Handle<i::JSObject>::cast(jsobj)->elements()));
13976 for (int i = 0; i < element_count; i++) { 13976 for (int i = 0; i < element_count; i++) {
13977 array->set(i, static_cast<ElementType>(i)); 13977 array->set(i, static_cast<ElementType>(i));
13978 } 13978 }
13979 13979
13980 // Test complex assignments 13980 // Test complex assignments
13981 result = CompileRun("function ee_op_test_complex_func(sum) {" 13981 result = CompileRun("function ee_op_test_complex_func(sum) {"
13982 " for (var i = 0; i < 40; ++i) {" 13982 " for (var i = 0; i < 40; ++i) {"
13983 " sum += (ext_array[i] += 1);" 13983 " sum += (ext_array[i] += 1);"
13984 " sum += (ext_array[i] -= 1);" 13984 " sum += (ext_array[i] -= 1);"
13985 " } " 13985 " } "
(...skipping 8094 matching lines...) Expand 10 before | Expand all | Expand 10 after
22080 env2->Global()->Set(v8_str("obj2"), object2); 22080 env2->Global()->Set(v8_str("obj2"), object2);
22081 ExpectString("typeof obj2.values", "function"); 22081 ExpectString("typeof obj2.values", "function");
22082 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values"))); 22082 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values")));
22083 22083
22084 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values"))); 22084 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values")));
22085 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2)); 22085 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2));
22086 auto ctx2 = v8::Utils::OpenHandle(*env2.local()); 22086 auto ctx2 = v8::Utils::OpenHandle(*env2.local());
22087 CHECK_EQ(fn2->GetCreationContext(), *ctx2); 22087 CHECK_EQ(fn2->GetCreationContext(), *ctx2);
22088 } 22088 }
22089 } 22089 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/function-tester.h ('k') | test/cctest/test-api-interceptors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698