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

Side by Side Diff: tools/js2c.py

Issue 623993002: Extend snapshot creation to generate 4-byte values (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | « no previous file | 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2012 the V8 project authors. All rights reserved. 3 # Copyright 2012 the V8 project authors. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 sources_bytes = "".join(sources.modules) 491 sources_bytes = "".join(sources.modules)
492 if compression_type == "off": 492 if compression_type == "off":
493 return sources_bytes 493 return sources_bytes
494 elif compression_type == "bz2": 494 elif compression_type == "bz2":
495 return bz2.compress(sources_bytes) 495 return bz2.compress(sources_bytes)
496 else: 496 else:
497 raise Error("Unknown compression type %s." % compression_type) 497 raise Error("Unknown compression type %s." % compression_type)
498 498
499 499
500 def PutInt(blob_file, value): 500 def PutInt(blob_file, value):
501 assert(value >= 0 and value < (1 << 20)) 501 assert(value >= 0 and value < (1 << 28))
502 size = 1 if (value < 1 << 6) else (2 if (value < 1 << 14) else 3) 502 size = 4
rmcilroy 2014/10/03 16:51:35 nit - please move this into an else branch below
baixo 2014/10/03 19:21:46 Done.
503 value_with_length = (value << 2) | size 503 if (value < 1 << 6):
504 size = 1
505 elif (value < 1 << 14):
506 size = 2
507 elif (value < 1 << 22):
508 size = 3
509 value_with_length = (value << 2) | (size - 1)
504 510
505 byte_sequence = bytearray() 511 byte_sequence = bytearray()
506 for i in xrange(size): 512 for i in xrange(size):
507 byte_sequence.append(value_with_length & 255) 513 byte_sequence.append(value_with_length & 255)
508 value_with_length >>= 8; 514 value_with_length >>= 8;
509 blob_file.write(byte_sequence) 515 blob_file.write(byte_sequence)
510 516
511 517
512 def PutStr(blob_file, value): 518 def PutStr(blob_file, value):
513 PutInt(blob_file, len(value)); 519 PutInt(blob_file, len(value));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 type: type parameter for NativesCollection template. 575 type: type parameter for NativesCollection template.
570 compression: type of compression used. [off|bz2] 576 compression: type of compression used. [off|bz2]
571 sources.js: JS internal sources or macros.py.""") 577 sources.js: JS internal sources or macros.py.""")
572 (options, args) = parser.parse_args() 578 (options, args) = parser.parse_args()
573 579
574 JS2C(args[3:], args[0], args[1], args[2], options.raw, options.startup_blob) 580 JS2C(args[3:], args[0], args[1], args[2], options.raw, options.startup_blob)
575 581
576 582
577 if __name__ == "__main__": 583 if __name__ == "__main__":
578 main() 584 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698