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

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

Issue 608012: Use binary search in GetScriptLineNumber. (Closed)
Patch Set: Created 10 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
« no previous file with comments | « src/handles.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 TEST(Regression236) { 310 TEST(Regression236) {
311 InitializeVM(); 311 InitializeVM();
312 v8::HandleScope scope; 312 v8::HandleScope scope;
313 313
314 Handle<Script> script = Factory::NewScript(Factory::empty_string()); 314 Handle<Script> script = Factory::NewScript(Factory::empty_string());
315 script->set_source(Heap::undefined_value()); 315 script->set_source(Heap::undefined_value());
316 CHECK_EQ(-1, GetScriptLineNumber(script, 0)); 316 CHECK_EQ(-1, GetScriptLineNumber(script, 0));
317 CHECK_EQ(-1, GetScriptLineNumber(script, 100)); 317 CHECK_EQ(-1, GetScriptLineNumber(script, 100));
318 CHECK_EQ(-1, GetScriptLineNumber(script, -1)); 318 CHECK_EQ(-1, GetScriptLineNumber(script, -1));
319 } 319 }
320
321
322 TEST(GetScriptLineNumber) {
323 LocalContext env;
324 v8::HandleScope scope;
325 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
326 const char function_f[] = "function f() {}";
327 const int max_rows = 1000;
328 const int buffer_size = max_rows + sizeof(function_f);
329 ScopedVector<char> buffer(buffer_size);
330 memset(buffer.start(), '\n', buffer_size - 1);
331 buffer[buffer_size - 1] = '\0';
332
333 for (int i = 0; i < max_rows; ++i) {
334 if (i > 0)
335 buffer[i - 1] = '\n';
336 memcpy(&buffer[i], function_f, sizeof(function_f) - 1);
337 v8::Handle<v8::String> script_body = v8::String::New(buffer.start());
338 v8::Script::Compile(script_body, &origin)->Run();
339 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
340 env->Global()->Get(v8::String::New("f")));
341 CHECK_EQ(i, f->GetScriptLineNumber());
342 }
343 }
OLDNEW
« no previous file with comments | « src/handles.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698