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

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

Issue 756423006: Optimize GetPrototype (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add test and add back Push/Pop Created 6 years 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 | « src/v8natives.js ('k') | no next file » | 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 24493 matching lines...) Expand 10 before | Expand all | Expand 10 after
24504 " function store() { MEM32[0] = 0; }" 24504 " function store() { MEM32[0] = 0; }"
24505 " return { store: store };" 24505 " return { store: store };"
24506 "}" 24506 "}"
24507 "var buffer = new ArrayBuffer(4);" 24507 "var buffer = new ArrayBuffer(4);"
24508 "Module(this, {}, buffer).store();" 24508 "Module(this, {}, buffer).store();"
24509 "buffer"; 24509 "buffer";
24510 24510
24511 result = CompileRun(store).As<v8::ArrayBuffer>(); 24511 result = CompileRun(store).As<v8::ArrayBuffer>();
24512 CHECK_EQ(should_be_neuterable, result->IsNeuterable()); 24512 CHECK_EQ(should_be_neuterable, result->IsNeuterable());
24513 } 24513 }
24514
24515
24516 TEST(GetPrototypeAccessControl) {
24517 i::FLAG_allow_natives_syntax = true;
24518 v8::Isolate* isolate = CcTest::isolate();
24519 v8::HandleScope handle_scope(isolate);
24520 LocalContext env;
24521
24522 v8::Handle<v8::ObjectTemplate> obj_template =
24523 v8::ObjectTemplate::New(isolate);
24524 obj_template->SetAccessCheckCallbacks(BlockEverythingNamed,
24525 BlockEverythingIndexed);
24526
24527 env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance());
24528
24529 {
24530 v8::TryCatch try_catch;
24531 CompileRun(
24532 "function f() { %_GetPrototype(prohibited); }"
24533 "%OptimizeFunctionOnNextCall(f);"
24534 "f();");
24535 CHECK(try_catch.HasCaught());
24536 }
24537 }
24538
24539
24540 TEST(GetPrototypeHidden) {
24541 i::FLAG_allow_natives_syntax = true;
24542 v8::Isolate* isolate = CcTest::isolate();
24543 v8::HandleScope handle_scope(isolate);
24544 LocalContext env;
24545
24546 Handle<FunctionTemplate> t = FunctionTemplate::New(isolate);
24547 t->SetHiddenPrototype(true);
24548 Handle<Object> proto = t->GetFunction()->NewInstance();
24549 Handle<Object> object = Object::New(isolate);
24550 Handle<Object> proto2 = Object::New(isolate);
24551 object->SetPrototype(proto);
24552 proto->SetPrototype(proto2);
24553
24554 env->Global()->Set(v8_str("object"), object);
24555 env->Global()->Set(v8_str("proto"), proto);
24556 env->Global()->Set(v8_str("proto2"), proto2);
24557
24558 v8::Handle<v8::Value> result = CompileRun("%_GetPrototype(object)");
24559 CHECK(result->Equals(proto2));
24560
24561 result = CompileRun(
24562 "function f() { return %_GetPrototype(object); }"
24563 "%OptimizeFunctionOnNextCall(f);"
24564 "f()");
24565 CHECK(result->Equals(proto2));
24566 }
OLDNEW
« no previous file with comments | « src/v8natives.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698