| OLD | NEW |
| 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 22 matching lines...) Expand all Loading... |
| 33 #include "compiler.h" | 33 #include "compiler.h" |
| 34 #include "disasm.h" | 34 #include "disasm.h" |
| 35 #include "disassembler.h" | 35 #include "disassembler.h" |
| 36 #include "execution.h" | 36 #include "execution.h" |
| 37 #include "factory.h" | 37 #include "factory.h" |
| 38 #include "platform.h" | 38 #include "platform.h" |
| 39 #include "cctest.h" | 39 #include "cctest.h" |
| 40 | 40 |
| 41 using namespace v8::internal; | 41 using namespace v8::internal; |
| 42 | 42 |
| 43 static v8::Persistent<v8::Context> env; | |
| 44 | |
| 45 // --- P r i n t E x t e n s i o n --- | 43 // --- P r i n t E x t e n s i o n --- |
| 46 | 44 |
| 47 class PrintExtension : public v8::Extension { | 45 class PrintExtension : public v8::Extension { |
| 48 public: | 46 public: |
| 49 PrintExtension() : v8::Extension("v8/print", kSource) { } | 47 PrintExtension() : v8::Extension("v8/print", kSource) { } |
| 50 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( | 48 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( |
| 51 v8::Handle<v8::String> name); | 49 v8::Handle<v8::String> name); |
| 52 static v8::Handle<v8::Value> Print(const v8::Arguments& args); | 50 static v8::Handle<v8::Value> Print(const v8::Arguments& args); |
| 53 private: | 51 private: |
| 54 static const char* kSource; | 52 static const char* kSource; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 74 } | 72 } |
| 75 printf("\n"); | 73 printf("\n"); |
| 76 return v8::Undefined(); | 74 return v8::Undefined(); |
| 77 } | 75 } |
| 78 | 76 |
| 79 | 77 |
| 80 static PrintExtension kPrintExtension; | 78 static PrintExtension kPrintExtension; |
| 81 v8::DeclareExtension kPrintExtensionDeclaration(&kPrintExtension); | 79 v8::DeclareExtension kPrintExtensionDeclaration(&kPrintExtension); |
| 82 | 80 |
| 83 | 81 |
| 84 static void InitializeVM() { | |
| 85 if (env.IsEmpty()) { | |
| 86 const char* extensions[] = { "v8/print", "v8/gc" }; | |
| 87 v8::ExtensionConfiguration config(2, extensions); | |
| 88 env = v8::Context::New(&config); | |
| 89 } | |
| 90 env->Enter(); | |
| 91 } | |
| 92 | |
| 93 | |
| 94 static MaybeObject* GetGlobalProperty(const char* name) { | 82 static MaybeObject* GetGlobalProperty(const char* name) { |
| 95 Handle<String> internalized_name = FACTORY->InternalizeUtf8String(name); | 83 Handle<String> internalized_name = FACTORY->InternalizeUtf8String(name); |
| 96 return Isolate::Current()->context()->global_object()->GetProperty( | 84 return Isolate::Current()->context()->global_object()->GetProperty( |
| 97 *internalized_name); | 85 *internalized_name); |
| 98 } | 86 } |
| 99 | 87 |
| 100 | 88 |
| 101 static void SetGlobalProperty(const char* name, Object* value) { | 89 static void SetGlobalProperty(const char* name, Object* value) { |
| 102 Isolate* isolate = Isolate::Current(); | 90 Isolate* isolate = Isolate::Current(); |
| 103 Handle<Object> object(value, isolate); | 91 Handle<Object> object(value, isolate); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 123 |
| 136 bool has_pending_exception; | 124 bool has_pending_exception; |
| 137 Handle<JSObject> global(Isolate::Current()->context()->global_object()); | 125 Handle<JSObject> global(Isolate::Current()->context()->global_object()); |
| 138 Execution::Call(fun, global, 0, NULL, &has_pending_exception); | 126 Execution::Call(fun, global, 0, NULL, &has_pending_exception); |
| 139 CHECK(!has_pending_exception); | 127 CHECK(!has_pending_exception); |
| 140 return GetGlobalProperty("result")->ToObjectChecked()->Number(); | 128 return GetGlobalProperty("result")->ToObjectChecked()->Number(); |
| 141 } | 129 } |
| 142 | 130 |
| 143 | 131 |
| 144 TEST(Inc) { | 132 TEST(Inc) { |
| 145 InitializeVM(); | 133 CcTest::InitializeVM(); |
| 146 v8::HandleScope scope(env->GetIsolate()); | 134 v8::HandleScope scope(CcTest::isolate()); |
| 147 CHECK_EQ(4.0, Inc(3)); | 135 CHECK_EQ(4.0, Inc(3)); |
| 148 } | 136 } |
| 149 | 137 |
| 150 | 138 |
| 151 static double Add(int x, int y) { | 139 static double Add(int x, int y) { |
| 152 Handle<JSFunction> fun = Compile("result = x + y;"); | 140 Handle<JSFunction> fun = Compile("result = x + y;"); |
| 153 if (fun.is_null()) return -1; | 141 if (fun.is_null()) return -1; |
| 154 | 142 |
| 155 SetGlobalProperty("x", Smi::FromInt(x)); | 143 SetGlobalProperty("x", Smi::FromInt(x)); |
| 156 SetGlobalProperty("y", Smi::FromInt(y)); | 144 SetGlobalProperty("y", Smi::FromInt(y)); |
| 157 bool has_pending_exception; | 145 bool has_pending_exception; |
| 158 Handle<JSObject> global(Isolate::Current()->context()->global_object()); | 146 Handle<JSObject> global(Isolate::Current()->context()->global_object()); |
| 159 Execution::Call(fun, global, 0, NULL, &has_pending_exception); | 147 Execution::Call(fun, global, 0, NULL, &has_pending_exception); |
| 160 CHECK(!has_pending_exception); | 148 CHECK(!has_pending_exception); |
| 161 return GetGlobalProperty("result")->ToObjectChecked()->Number(); | 149 return GetGlobalProperty("result")->ToObjectChecked()->Number(); |
| 162 } | 150 } |
| 163 | 151 |
| 164 | 152 |
| 165 TEST(Add) { | 153 TEST(Add) { |
| 166 InitializeVM(); | 154 CcTest::InitializeVM(); |
| 167 v8::HandleScope scope(env->GetIsolate()); | 155 v8::HandleScope scope(CcTest::isolate()); |
| 168 CHECK_EQ(5.0, Add(2, 3)); | 156 CHECK_EQ(5.0, Add(2, 3)); |
| 169 } | 157 } |
| 170 | 158 |
| 171 | 159 |
| 172 static double Abs(int x) { | 160 static double Abs(int x) { |
| 173 Handle<JSFunction> fun = Compile("if (x < 0) result = -x; else result = x;"); | 161 Handle<JSFunction> fun = Compile("if (x < 0) result = -x; else result = x;"); |
| 174 if (fun.is_null()) return -1; | 162 if (fun.is_null()) return -1; |
| 175 | 163 |
| 176 SetGlobalProperty("x", Smi::FromInt(x)); | 164 SetGlobalProperty("x", Smi::FromInt(x)); |
| 177 bool has_pending_exception; | 165 bool has_pending_exception; |
| 178 Handle<JSObject> global(Isolate::Current()->context()->global_object()); | 166 Handle<JSObject> global(Isolate::Current()->context()->global_object()); |
| 179 Execution::Call(fun, global, 0, NULL, &has_pending_exception); | 167 Execution::Call(fun, global, 0, NULL, &has_pending_exception); |
| 180 CHECK(!has_pending_exception); | 168 CHECK(!has_pending_exception); |
| 181 return GetGlobalProperty("result")->ToObjectChecked()->Number(); | 169 return GetGlobalProperty("result")->ToObjectChecked()->Number(); |
| 182 } | 170 } |
| 183 | 171 |
| 184 | 172 |
| 185 TEST(Abs) { | 173 TEST(Abs) { |
| 186 InitializeVM(); | 174 CcTest::InitializeVM(); |
| 187 v8::HandleScope scope(env->GetIsolate()); | 175 v8::HandleScope scope(CcTest::isolate()); |
| 188 CHECK_EQ(3.0, Abs(-3)); | 176 CHECK_EQ(3.0, Abs(-3)); |
| 189 } | 177 } |
| 190 | 178 |
| 191 | 179 |
| 192 static double Sum(int n) { | 180 static double Sum(int n) { |
| 193 Handle<JSFunction> fun = | 181 Handle<JSFunction> fun = |
| 194 Compile("s = 0; while (n > 0) { s += n; n -= 1; }; result = s;"); | 182 Compile("s = 0; while (n > 0) { s += n; n -= 1; }; result = s;"); |
| 195 if (fun.is_null()) return -1; | 183 if (fun.is_null()) return -1; |
| 196 | 184 |
| 197 SetGlobalProperty("n", Smi::FromInt(n)); | 185 SetGlobalProperty("n", Smi::FromInt(n)); |
| 198 bool has_pending_exception; | 186 bool has_pending_exception; |
| 199 Handle<JSObject> global(Isolate::Current()->context()->global_object()); | 187 Handle<JSObject> global(Isolate::Current()->context()->global_object()); |
| 200 Execution::Call(fun, global, 0, NULL, &has_pending_exception); | 188 Execution::Call(fun, global, 0, NULL, &has_pending_exception); |
| 201 CHECK(!has_pending_exception); | 189 CHECK(!has_pending_exception); |
| 202 return GetGlobalProperty("result")->ToObjectChecked()->Number(); | 190 return GetGlobalProperty("result")->ToObjectChecked()->Number(); |
| 203 } | 191 } |
| 204 | 192 |
| 205 | 193 |
| 206 TEST(Sum) { | 194 TEST(Sum) { |
| 207 InitializeVM(); | 195 CcTest::InitializeVM(); |
| 208 v8::HandleScope scope(env->GetIsolate()); | 196 v8::HandleScope scope(CcTest::isolate()); |
| 209 CHECK_EQ(5050.0, Sum(100)); | 197 CHECK_EQ(5050.0, Sum(100)); |
| 210 } | 198 } |
| 211 | 199 |
| 212 | 200 |
| 213 TEST(Print) { | 201 TEST(Print) { |
| 214 InitializeVM(); | 202 CcTest::InitializeVM(PRINT_EXTENSION); |
| 215 v8::HandleScope scope(env->GetIsolate()); | 203 v8::HandleScope scope(CcTest::isolate()); |
| 216 const char* source = "for (n = 0; n < 100; ++n) print(n, 1, 2);"; | 204 const char* source = "for (n = 0; n < 100; ++n) print(n, 1, 2);"; |
| 217 Handle<JSFunction> fun = Compile(source); | 205 Handle<JSFunction> fun = Compile(source); |
| 218 if (fun.is_null()) return; | 206 if (fun.is_null()) return; |
| 219 bool has_pending_exception; | 207 bool has_pending_exception; |
| 220 Handle<JSObject> global(Isolate::Current()->context()->global_object()); | 208 Handle<JSObject> global(Isolate::Current()->context()->global_object()); |
| 221 Execution::Call(fun, global, 0, NULL, &has_pending_exception); | 209 Execution::Call(fun, global, 0, NULL, &has_pending_exception); |
| 222 CHECK(!has_pending_exception); | 210 CHECK(!has_pending_exception); |
| 223 } | 211 } |
| 224 | 212 |
| 225 | 213 |
| 226 // The following test method stems from my coding efforts today. It | 214 // The following test method stems from my coding efforts today. It |
| 227 // tests all the functionality I have added to the compiler today | 215 // tests all the functionality I have added to the compiler today |
| 228 TEST(Stuff) { | 216 TEST(Stuff) { |
| 229 InitializeVM(); | 217 CcTest::InitializeVM(); |
| 230 v8::HandleScope scope(env->GetIsolate()); | 218 v8::HandleScope scope(CcTest::isolate()); |
| 231 const char* source = | 219 const char* source = |
| 232 "r = 0;\n" | 220 "r = 0;\n" |
| 233 "a = new Object;\n" | 221 "a = new Object;\n" |
| 234 "if (a == a) r+=1;\n" // 1 | 222 "if (a == a) r+=1;\n" // 1 |
| 235 "if (a != new Object()) r+=2;\n" // 2 | 223 "if (a != new Object()) r+=2;\n" // 2 |
| 236 "a.x = 42;\n" | 224 "a.x = 42;\n" |
| 237 "if (a.x == 42) r+=4;\n" // 4 | 225 "if (a.x == 42) r+=4;\n" // 4 |
| 238 "function foo() { var x = 87; return x; }\n" | 226 "function foo() { var x = 87; return x; }\n" |
| 239 "if (foo() == 87) r+=8;\n" // 8 | 227 "if (foo() == 87) r+=8;\n" // 8 |
| 240 "function bar() { var x; x = 99; return x; }\n" | 228 "function bar() { var x; x = 99; return x; }\n" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 251 CHECK(!fun.is_null()); | 239 CHECK(!fun.is_null()); |
| 252 bool has_pending_exception; | 240 bool has_pending_exception; |
| 253 Handle<JSObject> global(Isolate::Current()->context()->global_object()); | 241 Handle<JSObject> global(Isolate::Current()->context()->global_object()); |
| 254 Execution::Call(fun, global, 0, NULL, &has_pending_exception); | 242 Execution::Call(fun, global, 0, NULL, &has_pending_exception); |
| 255 CHECK(!has_pending_exception); | 243 CHECK(!has_pending_exception); |
| 256 CHECK_EQ(511.0, GetGlobalProperty("r")->ToObjectChecked()->Number()); | 244 CHECK_EQ(511.0, GetGlobalProperty("r")->ToObjectChecked()->Number()); |
| 257 } | 245 } |
| 258 | 246 |
| 259 | 247 |
| 260 TEST(UncaughtThrow) { | 248 TEST(UncaughtThrow) { |
| 261 InitializeVM(); | 249 CcTest::InitializeVM(); |
| 262 v8::HandleScope scope(env->GetIsolate()); | 250 v8::HandleScope scope(CcTest::isolate()); |
| 263 | 251 |
| 264 const char* source = "throw 42;"; | 252 const char* source = "throw 42;"; |
| 265 Handle<JSFunction> fun = Compile(source); | 253 Handle<JSFunction> fun = Compile(source); |
| 266 CHECK(!fun.is_null()); | 254 CHECK(!fun.is_null()); |
| 267 bool has_pending_exception; | 255 bool has_pending_exception; |
| 268 Isolate* isolate = fun->GetIsolate(); | 256 Isolate* isolate = fun->GetIsolate(); |
| 269 Handle<JSObject> global(isolate->context()->global_object()); | 257 Handle<JSObject> global(isolate->context()->global_object()); |
| 270 Execution::Call(fun, global, 0, NULL, &has_pending_exception); | 258 Execution::Call(fun, global, 0, NULL, &has_pending_exception); |
| 271 CHECK(has_pending_exception); | 259 CHECK(has_pending_exception); |
| 272 CHECK_EQ(42.0, isolate->pending_exception()->ToObjectChecked()->Number()); | 260 CHECK_EQ(42.0, isolate->pending_exception()->ToObjectChecked()->Number()); |
| 273 } | 261 } |
| 274 | 262 |
| 275 | 263 |
| 276 // Tests calling a builtin function from C/C++ code, and the builtin function | 264 // Tests calling a builtin function from C/C++ code, and the builtin function |
| 277 // performs GC. It creates a stack frame looks like following: | 265 // performs GC. It creates a stack frame looks like following: |
| 278 // | C (PerformGC) | | 266 // | C (PerformGC) | |
| 279 // | JS-to-C | | 267 // | JS-to-C | |
| 280 // | JS | | 268 // | JS | |
| 281 // | C-to-JS | | 269 // | C-to-JS | |
| 282 TEST(C2JSFrames) { | 270 TEST(C2JSFrames) { |
| 283 InitializeVM(); | 271 CcTest::InitializeVM(PRINT_EXTENSION | GC_EXTENSION); |
| 284 v8::HandleScope scope(env->GetIsolate()); | 272 v8::HandleScope scope(CcTest::isolate()); |
| 285 | 273 |
| 286 const char* source = "function foo(a) { gc(), print(a); }"; | 274 const char* source = "function foo(a) { gc(), print(a); }"; |
| 287 | 275 |
| 288 Handle<JSFunction> fun0 = Compile(source); | 276 Handle<JSFunction> fun0 = Compile(source); |
| 289 CHECK(!fun0.is_null()); | 277 CHECK(!fun0.is_null()); |
| 290 Isolate* isolate = fun0->GetIsolate(); | 278 Isolate* isolate = fun0->GetIsolate(); |
| 291 | 279 |
| 292 // Run the generated code to populate the global object with 'foo'. | 280 // Run the generated code to populate the global object with 'foo'. |
| 293 bool has_pending_exception; | 281 bool has_pending_exception; |
| 294 Handle<JSObject> global(Isolate::Current()->context()->global_object()); | 282 Handle<JSObject> global(Isolate::Current()->context()->global_object()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 310 ARRAY_SIZE(argv), | 298 ARRAY_SIZE(argv), |
| 311 argv, | 299 argv, |
| 312 &has_pending_exception); | 300 &has_pending_exception); |
| 313 CHECK(!has_pending_exception); | 301 CHECK(!has_pending_exception); |
| 314 } | 302 } |
| 315 | 303 |
| 316 | 304 |
| 317 // Regression 236. Calling InitLineEnds on a Script with undefined | 305 // Regression 236. Calling InitLineEnds on a Script with undefined |
| 318 // source resulted in crash. | 306 // source resulted in crash. |
| 319 TEST(Regression236) { | 307 TEST(Regression236) { |
| 320 InitializeVM(); | 308 CcTest::InitializeVM(); |
| 321 v8::HandleScope scope(env->GetIsolate()); | 309 v8::HandleScope scope(CcTest::isolate()); |
| 322 | 310 |
| 323 Handle<Script> script = FACTORY->NewScript(FACTORY->empty_string()); | 311 Handle<Script> script = FACTORY->NewScript(FACTORY->empty_string()); |
| 324 script->set_source(HEAP->undefined_value()); | 312 script->set_source(HEAP->undefined_value()); |
| 325 CHECK_EQ(-1, GetScriptLineNumber(script, 0)); | 313 CHECK_EQ(-1, GetScriptLineNumber(script, 0)); |
| 326 CHECK_EQ(-1, GetScriptLineNumber(script, 100)); | 314 CHECK_EQ(-1, GetScriptLineNumber(script, 100)); |
| 327 CHECK_EQ(-1, GetScriptLineNumber(script, -1)); | 315 CHECK_EQ(-1, GetScriptLineNumber(script, -1)); |
| 328 } | 316 } |
| 329 | 317 |
| 330 | 318 |
| 331 TEST(GetScriptLineNumber) { | 319 TEST(GetScriptLineNumber) { |
| 332 LocalContext env; | 320 CcTest::InitializeVM(); |
| 333 v8::HandleScope scope(env->GetIsolate()); | 321 v8::HandleScope scope(CcTest::isolate()); |
| 334 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); | 322 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); |
| 335 const char function_f[] = "function f() {}"; | 323 const char function_f[] = "function f() {}"; |
| 336 const int max_rows = 1000; | 324 const int max_rows = 1000; |
| 337 const int buffer_size = max_rows + sizeof(function_f); | 325 const int buffer_size = max_rows + sizeof(function_f); |
| 338 ScopedVector<char> buffer(buffer_size); | 326 ScopedVector<char> buffer(buffer_size); |
| 339 memset(buffer.start(), '\n', buffer_size - 1); | 327 memset(buffer.start(), '\n', buffer_size - 1); |
| 340 buffer[buffer_size - 1] = '\0'; | 328 buffer[buffer_size - 1] = '\0'; |
| 341 | 329 |
| 342 for (int i = 0; i < max_rows; ++i) { | 330 for (int i = 0; i < max_rows; ++i) { |
| 343 if (i > 0) | 331 if (i > 0) |
| 344 buffer[i - 1] = '\n'; | 332 buffer[i - 1] = '\n'; |
| 345 memcpy(&buffer[i], function_f, sizeof(function_f) - 1); | 333 memcpy(&buffer[i], function_f, sizeof(function_f) - 1); |
| 346 v8::Handle<v8::String> script_body = v8::String::New(buffer.start()); | 334 v8::Handle<v8::String> script_body = v8::String::New(buffer.start()); |
| 347 v8::Script::Compile(script_body, &origin)->Run(); | 335 v8::Script::Compile(script_body, &origin)->Run(); |
| 348 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | 336 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
| 349 env->Global()->Get(v8::String::New("f"))); | 337 CcTest::env()->Global()->Get(v8::String::New("f"))); |
| 350 CHECK_EQ(i, f->GetScriptLineNumber()); | 338 CHECK_EQ(i, f->GetScriptLineNumber()); |
| 351 } | 339 } |
| 352 } | 340 } |
| 353 | 341 |
| 354 | 342 |
| 355 // Test that optimized code for different closures is actually shared | 343 // Test that optimized code for different closures is actually shared |
| 356 // immediately by the FastNewClosureStub when run in the same context. | 344 // immediately by the FastNewClosureStub when run in the same context. |
| 357 TEST(OptimizedCodeSharing) { | 345 TEST(OptimizedCodeSharing) { |
| 358 // Skip test if --cache-optimized-code is not activated by default because | 346 // Skip test if --cache-optimized-code is not activated by default because |
| 359 // FastNewClosureStub that is baked into the snapshot is incorrect. | 347 // FastNewClosureStub that is baked into the snapshot is incorrect. |
| 360 if (!FLAG_cache_optimized_code) return; | 348 if (!FLAG_cache_optimized_code) return; |
| 361 FLAG_allow_natives_syntax = true; | 349 FLAG_allow_natives_syntax = true; |
| 362 InitializeVM(); | 350 CcTest::InitializeVM(); |
| 363 v8::HandleScope scope(env->GetIsolate()); | 351 v8::HandleScope scope(CcTest::isolate()); |
| 364 for (int i = 0; i < 10; i++) { | 352 for (int i = 0; i < 10; i++) { |
| 365 LocalContext env; | 353 LocalContext env; |
| 366 env->Global()->Set(v8::String::New("x"), v8::Integer::New(i)); | 354 env->Global()->Set(v8::String::New("x"), v8::Integer::New(i)); |
| 367 CompileRun("function MakeClosure() {" | 355 CompileRun("function MakeClosure() {" |
| 368 " return function() { return x; };" | 356 " return function() { return x; };" |
| 369 "}" | 357 "}" |
| 370 "var closure0 = MakeClosure();" | 358 "var closure0 = MakeClosure();" |
| 371 "%DebugPrint(closure0());" | 359 "%DebugPrint(closure0());" |
| 372 "%OptimizeFunctionOnNextCall(closure0);" | 360 "%OptimizeFunctionOnNextCall(closure0);" |
| 373 "%DebugPrint(closure0());" | 361 "%DebugPrint(closure0());" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 } else { | 404 } else { |
| 417 pc += d.InstructionDecode(decode_buffer, pc); | 405 pc += d.InstructionDecode(decode_buffer, pc); |
| 418 CHECK(strstr(decode_buffer.start(), smi_hex_buffer.start()) == NULL); | 406 CHECK(strstr(decode_buffer.start(), smi_hex_buffer.start()) == NULL); |
| 419 } | 407 } |
| 420 } | 408 } |
| 421 } | 409 } |
| 422 } | 410 } |
| 423 | 411 |
| 424 | 412 |
| 425 TEST(SplitConstantsInFullCompiler) { | 413 TEST(SplitConstantsInFullCompiler) { |
| 426 LocalContext env; | 414 CcTest::InitializeVM(); |
| 427 v8::HandleScope scope(env->GetIsolate()); | 415 v8::HandleScope scope(CcTest::isolate()); |
| 428 | 416 |
| 429 CompileRun("function f() { a = 12345678 }; f();"); | 417 CompileRun("function f() { a = 12345678 }; f();"); |
| 430 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); | 418 CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f")); |
| 431 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); | 419 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); |
| 432 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); | 420 CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f")); |
| 433 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); | 421 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); |
| 434 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); | 422 CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f")); |
| 435 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); | 423 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); |
| 436 CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f")); | 424 CheckCodeForUnsafeLiteral(GetJSFunction(CcTest::env()->Global(), "f")); |
| 437 } | 425 } |
| 438 #endif | 426 #endif |
| OLD | NEW |