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

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

Issue 11597007: Rename LookupSymbol calls to use Utf8 or OneByte in names. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « src/utils.h ('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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 const char* extensions[] = { "v8/print", "v8/gc" }; 87 const char* extensions[] = { "v8/print", "v8/gc" };
88 v8::ExtensionConfiguration config(2, extensions); 88 v8::ExtensionConfiguration config(2, extensions);
89 env = v8::Context::New(&config); 89 env = v8::Context::New(&config);
90 } 90 }
91 v8::HandleScope scope; 91 v8::HandleScope scope;
92 env->Enter(); 92 env->Enter();
93 } 93 }
94 94
95 95
96 static MaybeObject* GetGlobalProperty(const char* name) { 96 static MaybeObject* GetGlobalProperty(const char* name) {
97 Handle<String> symbol = FACTORY->LookupAsciiSymbol(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);
105 Handle<String> symbol = FACTORY->LookupAsciiSymbol(name); 105 Handle<String> symbol = FACTORY->LookupUtf8Symbol(name);
106 Handle<JSObject> global(Isolate::Current()->context()->global_object()); 106 Handle<JSObject> global(Isolate::Current()->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>(),
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 290
291 // Run the generated code to populate the global object with 'foo'. 291 // Run the generated code to populate the global object with 'foo'.
292 bool has_pending_exception; 292 bool has_pending_exception;
293 Handle<JSObject> global(Isolate::Current()->context()->global_object()); 293 Handle<JSObject> global(Isolate::Current()->context()->global_object());
294 Execution::Call(fun0, global, 0, NULL, &has_pending_exception); 294 Execution::Call(fun0, global, 0, NULL, &has_pending_exception);
295 CHECK(!has_pending_exception); 295 CHECK(!has_pending_exception);
296 296
297 Object* foo_symbol = FACTORY->LookupAsciiSymbol("foo")->ToObjectChecked(); 297 Object* foo_symbol =
298 FACTORY->LookupOneByteSymbol(STATIC_ASCII_VECTOR("foo"))->
299 ToObjectChecked();
298 MaybeObject* fun1_object = Isolate::Current()->context()->global_object()-> 300 MaybeObject* fun1_object = Isolate::Current()->context()->global_object()->
299 GetProperty(String::cast(foo_symbol)); 301 GetProperty(String::cast(foo_symbol));
300 Handle<Object> fun1(fun1_object->ToObjectChecked()); 302 Handle<Object> fun1(fun1_object->ToObjectChecked());
301 CHECK(fun1->IsJSFunction()); 303 CHECK(fun1->IsJSFunction());
302 304
303 Handle<Object> argv[] = { FACTORY->LookupAsciiSymbol("hello") }; 305 Handle<Object> argv[] =
306 { FACTORY->LookupOneByteSymbol(STATIC_ASCII_VECTOR("hello")) };
304 Execution::Call(Handle<JSFunction>::cast(fun1), 307 Execution::Call(Handle<JSFunction>::cast(fun1),
305 global, 308 global,
306 ARRAY_SIZE(argv), 309 ARRAY_SIZE(argv),
307 argv, 310 argv,
308 &has_pending_exception); 311 &has_pending_exception);
309 CHECK(!has_pending_exception); 312 CHECK(!has_pending_exception);
310 } 313 }
311 314
312 315
313 // Regression 236. Calling InitLineEnds on a Script with undefined 316 // Regression 236. Calling InitLineEnds on a Script with undefined
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 CompileRun("function f() { a = 12345678 }; f();"); 428 CompileRun("function f() { a = 12345678 }; f();");
426 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); 429 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f"));
427 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); 430 CompileRun("function f(x) { a = 12345678 + x}; f(1);");
428 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); 431 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f"));
429 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); 432 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);");
430 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); 433 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f"));
431 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); 434 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);");
432 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); 435 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f"));
433 } 436 }
434 #endif 437 #endif
OLDNEW
« no previous file with comments | « src/utils.h ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698