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

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

Issue 1775973002: Add GetProperty/GetElement to JSReceiver and use it where possible (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | test/cctest/test-object-observe.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 21 matching lines...) Expand all
32 32
33 #include "src/compiler.h" 33 #include "src/compiler.h"
34 #include "src/disasm.h" 34 #include "src/disasm.h"
35 #include "src/parsing/parser.h" 35 #include "src/parsing/parser.h"
36 #include "test/cctest/cctest.h" 36 #include "test/cctest/cctest.h"
37 37
38 using namespace v8::internal; 38 using namespace v8::internal;
39 39
40 static Handle<Object> GetGlobalProperty(const char* name) { 40 static Handle<Object> GetGlobalProperty(const char* name) {
41 Isolate* isolate = CcTest::i_isolate(); 41 Isolate* isolate = CcTest::i_isolate();
42 return Object::GetProperty( 42 return JSReceiver::GetProperty(isolate, isolate->global_object(), name)
43 isolate, isolate->global_object(), name).ToHandleChecked(); 43 .ToHandleChecked();
44 } 44 }
45 45
46 46
47 static void SetGlobalProperty(const char* name, Object* value) { 47 static void SetGlobalProperty(const char* name, Object* value) {
48 Isolate* isolate = CcTest::i_isolate(); 48 Isolate* isolate = CcTest::i_isolate();
49 Handle<Object> object(value, isolate); 49 Handle<Object> object(value, isolate);
50 Handle<String> internalized_name = 50 Handle<String> internalized_name =
51 isolate->factory()->InternalizeUtf8String(name); 51 isolate->factory()->InternalizeUtf8String(name);
52 Handle<JSObject> global(isolate->context()->global_object()); 52 Handle<JSObject> global(isolate->context()->global_object());
53 Runtime::SetObjectProperty(isolate, global, internalized_name, object, 53 Runtime::SetObjectProperty(isolate, global, internalized_name, object,
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 const char* source = "function foo(a) { gc(), print(a); }"; 220 const char* source = "function foo(a) { gc(), print(a); }";
221 221
222 Handle<JSFunction> fun0 = Compile(source); 222 Handle<JSFunction> fun0 = Compile(source);
223 CHECK(!fun0.is_null()); 223 CHECK(!fun0.is_null());
224 Isolate* isolate = fun0->GetIsolate(); 224 Isolate* isolate = fun0->GetIsolate();
225 225
226 // Run the generated code to populate the global object with 'foo'. 226 // Run the generated code to populate the global object with 'foo'.
227 Handle<JSObject> global(isolate->context()->global_object()); 227 Handle<JSObject> global(isolate->context()->global_object());
228 Execution::Call(isolate, fun0, global, 0, NULL).Check(); 228 Execution::Call(isolate, fun0, global, 0, NULL).Check();
229 229
230 Handle<String> foo_string = 230 Handle<Object> fun1 =
231 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("foo")); 231 JSReceiver::GetProperty(isolate, isolate->global_object(), "foo")
232 Handle<Object> fun1 = Object::GetProperty( 232 .ToHandleChecked();
233 isolate->global_object(), foo_string).ToHandleChecked();
234 CHECK(fun1->IsJSFunction()); 233 CHECK(fun1->IsJSFunction());
235 234
236 Handle<Object> argv[] = {isolate->factory()->InternalizeOneByteString( 235 Handle<Object> argv[] = {isolate->factory()->InternalizeOneByteString(
237 STATIC_CHAR_VECTOR("hello"))}; 236 STATIC_CHAR_VECTOR("hello"))};
238 Execution::Call(isolate, 237 Execution::Call(isolate,
239 Handle<JSFunction>::cast(fun1), 238 Handle<JSFunction>::cast(fun1),
240 global, 239 global,
241 arraysize(argv), 240 arraysize(argv),
242 argv).Check(); 241 argv).Check();
243 } 242 }
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 CompileRun("function f() { a = 12345678 }; f();"); 752 CompileRun("function f() { a = 12345678 }; f();");
754 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 753 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
755 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); 754 CompileRun("function f(x) { a = 12345678 + x}; f(1);");
756 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 755 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
757 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); 756 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);");
758 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 757 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
759 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); 758 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);");
760 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 759 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
761 } 760 }
762 #endif 761 #endif
OLDNEW
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | test/cctest/test-object-observe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698