| 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 20 matching lines...) Expand all Loading... |
| 31 #include "v8.h" | 31 #include "v8.h" |
| 32 | 32 |
| 33 #include "compiler.h" | 33 #include "compiler.h" |
| 34 #include "disasm.h" | 34 #include "disasm.h" |
| 35 #include "cctest.h" | 35 #include "cctest.h" |
| 36 | 36 |
| 37 using namespace v8::internal; | 37 using namespace v8::internal; |
| 38 | 38 |
| 39 static Handle<Object> GetGlobalProperty(const char* name) { | 39 static Handle<Object> GetGlobalProperty(const char* name) { |
| 40 Isolate* isolate = CcTest::i_isolate(); | 40 Isolate* isolate = CcTest::i_isolate(); |
| 41 Handle<String> internalized_name = | |
| 42 isolate->factory()->InternalizeUtf8String(name); | |
| 43 return Object::GetProperty( | 41 return Object::GetProperty( |
| 44 isolate->global_object(), internalized_name).ToHandleChecked(); | 42 isolate, isolate->global_object(), name).ToHandleChecked(); |
| 45 } | 43 } |
| 46 | 44 |
| 47 | 45 |
| 48 static void SetGlobalProperty(const char* name, Object* value) { | 46 static void SetGlobalProperty(const char* name, Object* value) { |
| 49 Isolate* isolate = CcTest::i_isolate(); | 47 Isolate* isolate = CcTest::i_isolate(); |
| 50 Handle<Object> object(value, isolate); | 48 Handle<Object> object(value, isolate); |
| 51 Handle<String> internalized_name = | 49 Handle<String> internalized_name = |
| 52 isolate->factory()->InternalizeUtf8String(name); | 50 isolate->factory()->InternalizeUtf8String(name); |
| 53 Handle<JSObject> global(isolate->context()->global_object()); | 51 Handle<JSObject> global(isolate->context()->global_object()); |
| 54 Runtime::SetObjectProperty(isolate, global, internalized_name, object, NONE, | 52 Runtime::SetObjectProperty(isolate, global, internalized_name, object, NONE, |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // Regression 236. Calling InitLineEnds on a Script with undefined | 250 // Regression 236. Calling InitLineEnds on a Script with undefined |
| 253 // source resulted in crash. | 251 // source resulted in crash. |
| 254 TEST(Regression236) { | 252 TEST(Regression236) { |
| 255 CcTest::InitializeVM(); | 253 CcTest::InitializeVM(); |
| 256 Isolate* isolate = CcTest::i_isolate(); | 254 Isolate* isolate = CcTest::i_isolate(); |
| 257 Factory* factory = isolate->factory(); | 255 Factory* factory = isolate->factory(); |
| 258 v8::HandleScope scope(CcTest::isolate()); | 256 v8::HandleScope scope(CcTest::isolate()); |
| 259 | 257 |
| 260 Handle<Script> script = factory->NewScript(factory->empty_string()); | 258 Handle<Script> script = factory->NewScript(factory->empty_string()); |
| 261 script->set_source(CcTest::heap()->undefined_value()); | 259 script->set_source(CcTest::heap()->undefined_value()); |
| 262 CHECK_EQ(-1, GetScriptLineNumber(script, 0)); | 260 CHECK_EQ(-1, Script::GetLineNumber(script, 0)); |
| 263 CHECK_EQ(-1, GetScriptLineNumber(script, 100)); | 261 CHECK_EQ(-1, Script::GetLineNumber(script, 100)); |
| 264 CHECK_EQ(-1, GetScriptLineNumber(script, -1)); | 262 CHECK_EQ(-1, Script::GetLineNumber(script, -1)); |
| 265 } | 263 } |
| 266 | 264 |
| 267 | 265 |
| 268 TEST(GetScriptLineNumber) { | 266 TEST(GetScriptLineNumber) { |
| 269 LocalContext context; | 267 LocalContext context; |
| 270 v8::HandleScope scope(CcTest::isolate()); | 268 v8::HandleScope scope(CcTest::isolate()); |
| 271 v8::ScriptOrigin origin = | 269 v8::ScriptOrigin origin = |
| 272 v8::ScriptOrigin(v8::String::NewFromUtf8(CcTest::isolate(), "test")); | 270 v8::ScriptOrigin(v8::String::NewFromUtf8(CcTest::isolate(), "test")); |
| 273 const char function_f[] = "function f() {}"; | 271 const char function_f[] = "function f() {}"; |
| 274 const int max_rows = 1000; | 272 const int max_rows = 1000; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 CompileRun("function f() { a = 12345678 }; f();"); | 371 CompileRun("function f() { a = 12345678 }; f();"); |
| 374 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 372 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
| 375 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); | 373 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); |
| 376 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 374 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
| 377 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); | 375 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); |
| 378 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 376 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
| 379 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); | 377 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); |
| 380 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 378 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
| 381 } | 379 } |
| 382 #endif | 380 #endif |
| OLD | NEW |