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

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

Issue 12210083: Renamed "symbols" to "internalized strings" throughout the code base, (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Yang's comments Created 7 years, 10 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-api.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 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->LookupUtf8Symbol(name); 97 Handle<String> internalized_name = FACTORY->InternalizeUtf8String(name);
98 return Isolate::Current()->context()->global_object()->GetProperty(*symbol); 98 return Isolate::Current()->context()->global_object()->GetProperty(
99 *internalized_name);
99 } 100 }
100 101
101 102
102 static void SetGlobalProperty(const char* name, Object* value) { 103 static void SetGlobalProperty(const char* name, Object* value) {
103 Isolate* isolate = Isolate::Current(); 104 Isolate* isolate = Isolate::Current();
104 Handle<Object> object(value); 105 Handle<Object> object(value);
105 Handle<String> symbol = FACTORY->LookupUtf8Symbol(name); 106 Handle<String> internalized_name = FACTORY->InternalizeUtf8String(name);
106 Handle<JSObject> global(Isolate::Current()->context()->global_object()); 107 Handle<JSObject> global(Isolate::Current()->context()->global_object());
107 SetProperty(isolate, global, symbol, object, NONE, kNonStrictMode); 108 SetProperty(isolate, global, internalized_name, object, NONE, kNonStrictMode);
108 } 109 }
109 110
110 111
111 static Handle<JSFunction> Compile(const char* source) { 112 static Handle<JSFunction> Compile(const char* source) {
112 Handle<String> source_code(FACTORY->NewStringFromUtf8(CStrVector(source))); 113 Handle<String> source_code(FACTORY->NewStringFromUtf8(CStrVector(source)));
113 Handle<SharedFunctionInfo> shared_function = 114 Handle<SharedFunctionInfo> shared_function =
114 Compiler::Compile(source_code, 115 Compiler::Compile(source_code,
115 Handle<String>(), 116 Handle<String>(),
116 0, 117 0,
117 0, 118 0,
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 288
288 Handle<JSFunction> fun0 = Compile(source); 289 Handle<JSFunction> fun0 = Compile(source);
289 CHECK(!fun0.is_null()); 290 CHECK(!fun0.is_null());
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_string =
298 FACTORY->LookupOneByteSymbol(STATIC_ASCII_VECTOR("foo"))-> 299 FACTORY->InternalizeOneByteString(STATIC_ASCII_VECTOR("foo"))->
299 ToObjectChecked(); 300 ToObjectChecked();
300 MaybeObject* fun1_object = Isolate::Current()->context()->global_object()-> 301 MaybeObject* fun1_object = Isolate::Current()->context()->global_object()->
301 GetProperty(String::cast(foo_symbol)); 302 GetProperty(String::cast(foo_string));
302 Handle<Object> fun1(fun1_object->ToObjectChecked()); 303 Handle<Object> fun1(fun1_object->ToObjectChecked());
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->InternalizeOneByteString(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);
313 } 314 }
314 315
315 316
316 // Regression 236. Calling InitLineEnds on a Script with undefined 317 // Regression 236. Calling InitLineEnds on a Script with undefined
(...skipping 111 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-api.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698