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

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

Issue 660095: Merge revision 3813 to 3930 from bleeding_edge to partial snapshots branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
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 | 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 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 114
115 static Handle<JSFunction> Compile(const char* source) { 115 static Handle<JSFunction> Compile(const char* source) {
116 Handle<String> source_code(Factory::NewStringFromUtf8(CStrVector(source))); 116 Handle<String> source_code(Factory::NewStringFromUtf8(CStrVector(source)));
117 Handle<JSFunction> boilerplate = Compiler::Compile(source_code, 117 Handle<JSFunction> boilerplate = Compiler::Compile(source_code,
118 Handle<String>(), 118 Handle<String>(),
119 0, 119 0,
120 0, 120 0,
121 NULL, 121 NULL,
122 NULL, 122 NULL,
123 Handle<String>::null(),
123 NOT_NATIVES_CODE); 124 NOT_NATIVES_CODE);
124 return Factory::NewFunctionFromBoilerplate(boilerplate, 125 return Factory::NewFunctionFromBoilerplate(boilerplate,
125 Top::global_context()); 126 Top::global_context());
126 } 127 }
127 128
128 129
129 static double Inc(int x) { 130 static double Inc(int x) {
130 const char* source = "result = %d + 1;"; 131 const char* source = "result = %d + 1;";
131 EmbeddedVector<char, 512> buffer; 132 EmbeddedVector<char, 512> buffer;
132 OS::SNPrintF(buffer, source, x); 133 OS::SNPrintF(buffer, source, x);
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 TEST(Regression236) { 316 TEST(Regression236) {
316 InitializeVM(); 317 InitializeVM();
317 v8::HandleScope scope; 318 v8::HandleScope scope;
318 319
319 Handle<Script> script = Factory::NewScript(Factory::empty_string()); 320 Handle<Script> script = Factory::NewScript(Factory::empty_string());
320 script->set_source(Heap::undefined_value()); 321 script->set_source(Heap::undefined_value());
321 CHECK_EQ(-1, GetScriptLineNumber(script, 0)); 322 CHECK_EQ(-1, GetScriptLineNumber(script, 0));
322 CHECK_EQ(-1, GetScriptLineNumber(script, 100)); 323 CHECK_EQ(-1, GetScriptLineNumber(script, 100));
323 CHECK_EQ(-1, GetScriptLineNumber(script, -1)); 324 CHECK_EQ(-1, GetScriptLineNumber(script, -1));
324 } 325 }
326
327
328 TEST(GetScriptLineNumber) {
329 LocalContext env;
330 v8::HandleScope scope;
331 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
332 const char function_f[] = "function f() {}";
333 const int max_rows = 1000;
334 const int buffer_size = max_rows + sizeof(function_f);
335 ScopedVector<char> buffer(buffer_size);
336 memset(buffer.start(), '\n', buffer_size - 1);
337 buffer[buffer_size - 1] = '\0';
338
339 for (int i = 0; i < max_rows; ++i) {
340 if (i > 0)
341 buffer[i - 1] = '\n';
342 memcpy(&buffer[i], function_f, sizeof(function_f) - 1);
343 v8::Handle<v8::String> script_body = v8::String::New(buffer.start());
344 v8::Script::Compile(script_body, &origin)->Run();
345 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
346 env->Global()->Get(v8::String::New("f")));
347 CHECK_EQ(i, f->GetScriptLineNumber());
348 }
349 }
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