[llvm-commits] CVS: llvm-www/demo/index.cgi
Chris Lattner
lattner at cs.uiuc.edu
Thu Dec 9 20:51:52 PST 2004
Changes in directory llvm-www/demo:
index.cgi updated: 1.32 -> 1.33
---
Log message:
Add Stacker support, a 20s timeout, and locking to only allow one person at
a time to nuke nuke nuke our site.
Reid wrote this patch, thanks!!
---
Diffs of the changes: (+95 -57)
Index: llvm-www/demo/index.cgi
diff -u llvm-www/demo/index.cgi:1.32 llvm-www/demo/index.cgi:1.33
--- llvm-www/demo/index.cgi:1.32 Thu Dec 9 01:46:53 2004
+++ llvm-www/demo/index.cgi Thu Dec 9 22:51:42 2004
@@ -5,29 +5,31 @@
# doing remote web JO99C compilations. (It could still be used for that
# purpose, though the two scripts have diverged somewhat.)
#
-# Last modified $Date: 2004/12/09 07:46:53 $
+# Last modified $Date: 2004/12/10 04:51:42 $
#
+use strict;
use CGI;
use POSIX;
use Mail::Send;
$| = 1;
-my $DisableForm = 0;
open( STDERR, ">&STDOUT" ) or die "can't redirect stderr to stdout";
if ( !-d "/tmp/webcompile" ) { mkdir( "/tmp/webcompile", 0777 ); }
-$LOGFILE = '/tmp/webcompile/log.txt';
-$FORM_URL = 'index.cgi';
-$CONTACT_ADDRESS = 'gaeke -at- uiuc.edu';
-$LOGO_IMAGE_URL = 'cathead.png';
- at PREPENDPATHDIRS =
- ( '/home/vadve/gaeke/llvm/Release/bin', '/home/vadve/gaeke/bin' );
-$ENV{'LLVM_LIB_SEARCH_PATH'} =
- '/home/vadve/lattner/local/x86/llvm-gcc/bytecode-libs';
+my $LOGFILE = '/tmp/webcompile/log.txt';
+my $FORM_URL = 'index.cgi';
+my $CONTACT_ADDRESS = 'gaeke -at- x10sys.com';
+my $LOGO_IMAGE_URL = 'cathead.png';
+my $TIMEOUTAMOUNT = 20;
+
$ENV{'LD_LIBRARY_PATH'} = '/home/vadve/shared/localtools/fc1/lib/';
+$ENV{'LLVM_LIB_SEARCH_PATH'} = '/home/llvm/install/bytecode-libs';
+my @PREPENDPATHDIRS =
+ ( '/home/vadve/gaeke/llvm/Release/bin', '/home/vadve/gaeke/bin',
+ '/home/vadve/gaeke/llvm/projects/Stacker/Release/bin' );
sub getname {
my ($extension) = @_;
@@ -38,9 +40,12 @@
}
}
+my $c;
+
sub barf {
print "<b>", @_, "</b>\n";
print $c->end_html;
+ system("rm -f /tmp/webcompile/locked");
exit 1;
}
@@ -87,7 +92,7 @@
sub syntaxHighlightLLVM {
my ($input) = @_;
$input =~ s@\b(void|bool|sbyte|ubyte|short|ushort|int|uint|long|ulong|float|double|type|label|opaque)\b@<span class="llvm_type">$1</span>@g;
- $input =~ s@\b(add|sub|mul|div|rem|and|or|xor|setne|seteq|setlt|setgt|setle|setge|phi|call|cast|to|shl|shr|vaarg|vanext|ret|br|switch|invoke|unwind|unreachable|malloc|alloca|free|load|store|getelementptr|begin|end|true|false|declare|global|constant|const|internal|uninitialized|external|implementation|linkonce|weak|appending|null|undef|to|except|not|target|endian|pointersize|big|little|volatile|deplibs)\b@<span class="llvm_keyword">$1</span>@g;
+ $input =~ s@\b(add|sub|mul|div|rem|and|or|xor|setne|seteq|setlt|setgt|setle|setge|phi|call|cast|to|shl|shr|vaarg|vanext|ret|br|switch|invoke|unwind|malloc|alloca|free|load|store|getelementptr|begin|end|true|false|declare|global|constant|const|internal|uninitialized|external|implementation|linkonce|weak|appending|null|to|except|not|target|endian|pointersize|big|little|volatile)\b@<span class="llvm_keyword">$1</span>@g;
return $input;
}
@@ -95,8 +100,7 @@
my ( $recipient, $body ) = @_;
my $msg =
new Mail::Send( Subject => "LLVM Demo Page Run", To => $recipient );
- local ($fh);
- $fh = $msg->open();
+ my $fh = $msg->open();
print $fh $body;
$fh->close();
}
@@ -126,9 +130,19 @@
EOF
if ($LOGO_IMAGE_URL) {
- print "<img align=right width=166 height=184 src=\"$LOGO_IMAGE_URL\" />";
+ print "<img align=right width=100 height=114 src=\"$LOGO_IMAGE_URL\" />";
+}
+
+if ( -f "/tmp/webcompile/locked" ) {
+
+print "<p>Bitter Melon the cat says, 'this page is already in use by someone else at this ";
+print "time, try reloading in a second or two. Meow!'</p>\n";
+exit 0;
+
}
+system("touch /tmp/webcompile/locked");
+
print <<END;
<p>Bitter Melon the cat says, paste a C/C++ program in the text box or upload
@@ -146,7 +160,7 @@
print $c->filefield( -name => 'uploaded_file', -default => '' );
print "<p>Or type your source code in below:</p>\n";
-$source = $c->param('source');
+my $source = $c->param('source');
print $c->textarea(
-name => "source",
-rows => 12,
@@ -159,7 +173,7 @@
print "<p>By the way, what language is this code in?: ",
$c->radio_group(
-name => 'language',
- -values => [ 'C', 'C++' ],
+ -values => [ 'C', 'C++', 'Stacker' ],
-default => 'C'
);
print "</p>\n";
@@ -186,16 +200,26 @@
print "</td><td>";
print
-"<p>Would you believe the cat even has a stopwatch? Click here to get detailed compilation statistics and timings from each pass.</p><ul>",
+"<p>Would you believe that BitterMelon even has a stopwatch? Click here to get detailed compilation statistic and timings from each pass.</p><ul>",
$c->checkbox(
-name => 'showstats',
-label => 'Show detailed statistics'
),
"</ul>";
+
+print "</td><td>";
+
+print "<p>And further, the cat can even produce detailed information about the bytecode file generated!",
+ " Click here to get a detailed description of the various artifacts in the bytecode file your program generates.</p><ul>",
+ $c->checkbox(
+ -name => 'showbcanalysis',
+ -label => 'Show detailed bytecode information'
+ ),
+ "</ul>";
+
print "</td></tr></table>";
-print "<p>", $c->submit, "\n" if (!$DisableForm);
-print $c->endform;
+print "<p>", $c->submit, "\n", $c->endform;
print "\n<p>If you have questions about the LLVM code generated by the
front-end, please <a href='/docs/FAQ.html#cfe_code'>check the FAQ</a> (e.g.,
@@ -210,30 +234,43 @@
sub sanitychecktools {
my $sanitycheckfail = '';
- barf("The demo page is currently down due to high load, please try again later!")
- if ($DisableForm);
-
# insert tool-specific sanity checks here
- $sanitycheckfail .= ' gccas' if `gccas --help 2>&1` !~ /assembler for GCC/;
+ $sanitycheckfail .= ' gccas'
+ if `gccas --help 2>&1` !~ /assembler for GCC/;
+
$sanitycheckfail .= ' llvm-dis'
if `llvm-dis --help 2>&1` !~ /ll disassembler/;
+
$sanitycheckfail .= ' llvm-gcc'
- if `llvm-gcc --version 2>&1` !~ /Free Software Foundation/;
+ if ( `llvm-gcc --version 2>&1` !~ /Free Software Foundation/ );
+
$sanitycheckfail .= ' gccld'
if `gccld --help 2>&1` !~ /llvm linker for GCC/;
+
+ $sanitycheckfail .= ' llvm-bcanalyzer'
+ if `llvm-bcanalyzer --help 2>&1` !~ /bcanalyzer/;
+
barf(
-"The demo page is currently unavailable. [tools: ($sanitycheckfail ) failed sanity check]"
+"<br/>The demo page is currently unavailable. [tools: ($sanitycheckfail ) failed sanity check]"
)
if $sanitycheckfail;
}
+
sanitychecktools();
sub try_run {
my ( $program, $commandline, $outputFile ) = @_;
+ my $retcode = 0;
- #print "<p>Command line was <tt>$commandline</tt></p>\n";
- my $retcode = system($commandline);
- #print "<p>Finished running command.</p>\n";
+ eval {
+ local $SIG{ALRM} = sub { die "timeout"; };
+ alarm $TIMEOUTAMOUNT;
+ $retcode = system($commandline);
+ alarm 0;
+ };
+ if ( $@ and $@ =~ /timeout/ ) {
+ barf("Program $program took too long, compile time limited for the web script, sorry!.\n");
+ }
if ( -s $outputFile ) {
print scalar dumpFile( "Output from $program", $outputFile );
}
@@ -251,25 +288,27 @@
}
}
-%suffixes = (
+my %suffixes = (
'Java' => '.java',
'JO99' => '.jo9',
'C' => '.c',
'C++' => '.cc',
+ 'Stacker' => '.st',
'preprocessed C' => '.i',
'preprocessed C++' => '.ii'
);
-%languages = (
+my %languages = (
'.jo9' => 'JO99',
'.java' => 'Java',
'.c' => 'C',
'.i' => 'preprocessed C',
'.ii' => 'preprocessed C++',
'.cc' => 'C++',
- '.cpp' => 'C++'
+ '.cpp' => 'C++',
+ '.st' => 'Stacker'
);
-$uploaded_file_name = $c->param('uploaded_file');
+my $uploaded_file_name = $c->param('uploaded_file');
if ($uploaded_file_name) {
if ($source) {
barf(
@@ -306,19 +345,28 @@
my $inputFile = writeIntoFile( $extension, $source );
my $pid = $$;
- my $bytecodeFile = getname(".o");
+ my $bytecodeFile = getname(".bc");
my $outputFile = getname(".llvm-gcc.out");
my $timerFile = getname(".llvm-gcc.time");
my $stats = '';
- $stats = "-Wa,--stats,--time-passes,--info-output-file=$timerFile"
- if ( $c->param('showstats') );
- try_run( "llvm C/C++ front-end (llvm-gcc)",
- "llvm-gcc -W -Wall -O2 $stats -o $bytecodeFile -c $inputFile > $outputFile 2>&1",
+ if ( $extension eq ".st" ) {
+ $stats = "-stats -time-passes "
+ if ( $c->param('showstats') );
+ try_run( "llvm Stacker front-end (stkrc)",
+ "stkrc $stats -o $bytecodeFile $inputFile > $outputFile 2>&1",
$outputFile );
+ } else {
+ $stats = "-Wa,--stats,--time-passes,--info-output-file=$timerFile"
+ if ( $c->param('showstats') );
+ try_run( "llvm C/C++ front-end (llvm-gcc)",
+ "llvm-gcc -W -Wall -O2 $stats -o $bytecodeFile -c $inputFile > $outputFile 2>&1",
+ $outputFile );
+ }
+
if ( $c->param('showstats') && -s $timerFile ) {
- ( $UnhilightedResult, $HtmlResult ) =
- dumpFile( "Statistics for C/C++ front-end", $timerFile );
+ my ( $UnhilightedResult, $HtmlResult ) =
+ dumpFile( "Statistics for front-end compilation", $timerFile );
print "$HtmlResult\n";
}
@@ -328,7 +376,6 @@
my $timerFile = getname(".gccld.time");
$stats = "--stats --time-passes --info-output-file=$timerFile"
if ( $c->param('showstats') );
- print " Running optimizing linker.\n";
my $tmpFile = getname(".bc");
try_run(
"optimizing linker (gccld)",
@@ -338,7 +385,7 @@
system("mv $tmpFile $bytecodeFile");
if ( $c->param('showstats') && -s $timerFile ) {
- ( $UnhilightedResult, $HtmlResult ) =
+ my ( $UnhilightedResult, $HtmlResult ) =
dumpFile( "Statistics for optimizing linker", $timerFile );
print "$HtmlResult\n";
}
@@ -367,26 +414,17 @@
else {
print "<p>Hmm, that's weird, llvm-dis didn't produce any output.</p>\n";
}
- addlog( $source, $pid, $UnhilightedResult );
- my ( $ip, $host, $lg, $lines );
- chomp( $lines = `wc -l < $inputFile` );
- $lg = $c->param('language');
- $ip = $c->remote_addr();
- chomp( $host = `host $ip` ) if $ip;
- mailto( 'lattner at cs.uiuc.edu',
- "--- Query: ---\nFrom: ($ip) $host\nInput: $lines lines of $lg\n"
- . "C++ demangle = "
- . ( $c->param('cxxdemangle') ? 1 : 0 )
- . ", Link opt = "
- . ( $c->param('linkopt') ? 1 : 0 ) . "\n\n"
- . ", Show stats = "
- . ( $c->param('showstats') ? 1 : 0 ) . "\n\n"
- . "--- Source: ---\n$source\n"
- . "--- Result: ---\n$UnhilightedResult\n" );
+ if ( $c->param('showbcanalysis') ) {
+ my $analFile = getname(".bca");
+ try_run( "llvm-bcanalyzer", "llvm-bcanalyzer $bytecodeFile > $analFile 2>&1",
+ $analFile);
+ }
+ addlog( $source, $pid, $UnhilightedResult );
unlink( $inputFile, $bytecodeFile, $outputFile, $disassemblyFile );
}
print $c->hr, "<address>$CONTACT_ADDRESS</address>", $c->end_html;
+system("rm /tmp/webcompile/locked");
exit 0;
More information about the llvm-commits
mailing list