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

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

Issue 12300018: Made Isolate a mandatory parameter for everything Handle-related. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed CreateCode calls. Be nicer to MIPS. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-assembler-x64.cc ('k') | test/cctest/test-debug.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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 95
96 static MaybeObject* GetGlobalProperty(const char* name) { 96 static MaybeObject* GetGlobalProperty(const char* name) {
97 Handle<String> symbol = FACTORY->LookupUtf8Symbol(name); 97 Handle<String> symbol = FACTORY->LookupUtf8Symbol(name);
98 return Isolate::Current()->context()->global_object()->GetProperty(*symbol); 98 return Isolate::Current()->context()->global_object()->GetProperty(*symbol);
99 } 99 }
100 100
101 101
102 static void SetGlobalProperty(const char* name, Object* value) { 102 static void SetGlobalProperty(const char* name, Object* value) {
103 Isolate* isolate = Isolate::Current(); 103 Isolate* isolate = Isolate::Current();
104 Handle<Object> object(value); 104 Handle<Object> object(value, isolate);
105 Handle<String> symbol = FACTORY->LookupUtf8Symbol(name); 105 Handle<String> symbol = isolate->factory()->LookupUtf8Symbol(name);
106 Handle<JSObject> global(Isolate::Current()->context()->global_object()); 106 Handle<JSObject> global(isolate->context()->global_object());
107 SetProperty(isolate, global, symbol, object, NONE, kNonStrictMode); 107 SetProperty(isolate, global, symbol, object, NONE, kNonStrictMode);
108 } 108 }
109 109
110 110
111 static Handle<JSFunction> Compile(const char* source) { 111 static Handle<JSFunction> Compile(const char* source) {
112 Handle<String> source_code(FACTORY->NewStringFromUtf8(CStrVector(source))); 112 Handle<String> source_code(FACTORY->NewStringFromUtf8(CStrVector(source)));
113 Handle<SharedFunctionInfo> shared_function = 113 Handle<SharedFunctionInfo> shared_function =
114 Compiler::Compile(source_code, 114 Compiler::Compile(source_code,
115 Handle<String>(), 115 Handle<String>(),
116 0, 116 0,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 259
260 TEST(UncaughtThrow) { 260 TEST(UncaughtThrow) {
261 InitializeVM(); 261 InitializeVM();
262 v8::HandleScope scope; 262 v8::HandleScope scope;
263 263
264 const char* source = "throw 42;"; 264 const char* source = "throw 42;";
265 Handle<JSFunction> fun = Compile(source); 265 Handle<JSFunction> fun = Compile(source);
266 CHECK(!fun.is_null()); 266 CHECK(!fun.is_null());
267 bool has_pending_exception; 267 bool has_pending_exception;
268 Handle<JSObject> global(Isolate::Current()->context()->global_object()); 268 Isolate* isolate = fun->GetIsolate();
269 Handle<JSObject> global(isolate->context()->global_object());
269 Execution::Call(fun, global, 0, NULL, &has_pending_exception); 270 Execution::Call(fun, global, 0, NULL, &has_pending_exception);
270 CHECK(has_pending_exception); 271 CHECK(has_pending_exception);
271 CHECK_EQ(42.0, Isolate::Current()->pending_exception()-> 272 CHECK_EQ(42.0, isolate->pending_exception()->ToObjectChecked()->Number());
272 ToObjectChecked()->Number());
273 } 273 }
274 274
275 275
276 // Tests calling a builtin function from C/C++ code, and the builtin function 276 // Tests calling a builtin function from C/C++ code, and the builtin function
277 // performs GC. It creates a stack frame looks like following: 277 // performs GC. It creates a stack frame looks like following:
278 // | C (PerformGC) | 278 // | C (PerformGC) |
279 // | JS-to-C | 279 // | JS-to-C |
280 // | JS | 280 // | JS |
281 // | C-to-JS | 281 // | C-to-JS |
282 TEST(C2JSFrames) { 282 TEST(C2JSFrames) {
283 InitializeVM(); 283 InitializeVM();
284 v8::HandleScope scope; 284 v8::HandleScope scope;
285 285
286 const char* source = "function foo(a) { gc(), print(a); }"; 286 const char* source = "function foo(a) { gc(), print(a); }";
287 287
288 Handle<JSFunction> fun0 = Compile(source); 288 Handle<JSFunction> fun0 = Compile(source);
289 CHECK(!fun0.is_null()); 289 CHECK(!fun0.is_null());
290 Isolate* isolate = fun0->GetIsolate();
290 291
291 // Run the generated code to populate the global object with 'foo'. 292 // Run the generated code to populate the global object with 'foo'.
292 bool has_pending_exception; 293 bool has_pending_exception;
293 Handle<JSObject> global(Isolate::Current()->context()->global_object()); 294 Handle<JSObject> global(Isolate::Current()->context()->global_object());
294 Execution::Call(fun0, global, 0, NULL, &has_pending_exception); 295 Execution::Call(fun0, global, 0, NULL, &has_pending_exception);
295 CHECK(!has_pending_exception); 296 CHECK(!has_pending_exception);
296 297
297 Object* foo_symbol = 298 Object* foo_symbol =
298 FACTORY->LookupOneByteSymbol(STATIC_ASCII_VECTOR("foo"))-> 299 FACTORY->LookupOneByteSymbol(STATIC_ASCII_VECTOR("foo"))->
299 ToObjectChecked(); 300 ToObjectChecked();
300 MaybeObject* fun1_object = Isolate::Current()->context()->global_object()-> 301 MaybeObject* fun1_object = isolate->context()->global_object()->
301 GetProperty(String::cast(foo_symbol)); 302 GetProperty(String::cast(foo_symbol));
302 Handle<Object> fun1(fun1_object->ToObjectChecked()); 303 Handle<Object> fun1(fun1_object->ToObjectChecked(), isolate);
303 CHECK(fun1->IsJSFunction()); 304 CHECK(fun1->IsJSFunction());
304 305
305 Handle<Object> argv[] = 306 Handle<Object> argv[] =
306 { FACTORY->LookupOneByteSymbol(STATIC_ASCII_VECTOR("hello")) }; 307 { FACTORY->LookupOneByteSymbol(STATIC_ASCII_VECTOR("hello")) };
307 Execution::Call(Handle<JSFunction>::cast(fun1), 308 Execution::Call(Handle<JSFunction>::cast(fun1),
308 global, 309 global,
309 ARRAY_SIZE(argv), 310 ARRAY_SIZE(argv),
310 argv, 311 argv,
311 &has_pending_exception); 312 &has_pending_exception);
312 CHECK(!has_pending_exception); 313 CHECK(!has_pending_exception);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 CompileRun("function f() { a = 12345678 }; f();"); 429 CompileRun("function f() { a = 12345678 }; f();");
429 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); 430 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f"));
430 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); 431 CompileRun("function f(x) { a = 12345678 + x}; f(1);");
431 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); 432 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f"));
432 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); 433 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);");
433 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); 434 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f"));
434 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); 435 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);");
435 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); 436 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f"));
436 } 437 }
437 #endif 438 #endif
OLDNEW
« no previous file with comments | « test/cctest/test-assembler-x64.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698