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

Side by Side Diff: src/runtime.cc

Issue 27324: Small fixes to allow all-in-one compilation.
Patch Set: Created 11 years, 9 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/interpreter-irregexp.cc ('k') | src/v8.h » ('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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 double name = (obj)->Number(); 77 double name = (obj)->Number();
78 78
79 // Call the specified converter on the object *comand store the result in 79 // Call the specified converter on the object *comand store the result in
80 // a variable of the specified type with the given name. If the 80 // a variable of the specified type with the given name. If the
81 // object is not a Number call IllegalOperation and return. 81 // object is not a Number call IllegalOperation and return.
82 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \ 82 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \
83 RUNTIME_ASSERT(obj->IsNumber()); \ 83 RUNTIME_ASSERT(obj->IsNumber()); \
84 type name = NumberTo##Type(obj); 84 type name = NumberTo##Type(obj);
85 85
86 // Non-reentrant string buffer for efficient general use in this file. 86 // Non-reentrant string buffer for efficient general use in this file.
87 static StaticResource<StringInputBuffer> string_input_buffer; 87 static StaticResource<StringInputBuffer> runtime_string_input_buffer;
88 88
89 89
90 static Object* IllegalOperation() { 90 static Object* IllegalOperation() {
91 return Top::Throw(Heap::illegal_access_symbol()); 91 return Top::Throw(Heap::illegal_access_symbol());
92 } 92 }
93 93
94 94
95 static Object* Runtime_CloneObjectLiteralBoilerplate(Arguments args) { 95 static Object* Runtime_CloneObjectLiteralBoilerplate(Arguments args) {
96 CONVERT_CHECKED(JSObject, boilerplate, args[0]); 96 CONVERT_CHECKED(JSObject, boilerplate, args[0]);
97 return Heap::CopyJSObject(boilerplate); 97 return Heap::CopyJSObject(boilerplate);
(...skipping 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 const char hex_chars[] = "0123456789ABCDEF"; 2308 const char hex_chars[] = "0123456789ABCDEF";
2309 NoHandleAllocation ha; 2309 NoHandleAllocation ha;
2310 ASSERT(args.length() == 1); 2310 ASSERT(args.length() == 1);
2311 CONVERT_CHECKED(String, source, args[0]); 2311 CONVERT_CHECKED(String, source, args[0]);
2312 2312
2313 source->TryFlattenIfNotFlat(StringShape(source)); 2313 source->TryFlattenIfNotFlat(StringShape(source));
2314 2314
2315 int escaped_length = 0; 2315 int escaped_length = 0;
2316 int length = source->length(); 2316 int length = source->length();
2317 { 2317 {
2318 Access<StringInputBuffer> buffer(&string_input_buffer); 2318 Access<StringInputBuffer> buffer(&runtime_string_input_buffer);
2319 buffer->Reset(source); 2319 buffer->Reset(source);
2320 while (buffer->has_more()) { 2320 while (buffer->has_more()) {
2321 uint16_t character = buffer->GetNext(); 2321 uint16_t character = buffer->GetNext();
2322 if (character >= 256) { 2322 if (character >= 256) {
2323 escaped_length += 6; 2323 escaped_length += 6;
2324 } else if (IsNotEscaped(character)) { 2324 } else if (IsNotEscaped(character)) {
2325 escaped_length++; 2325 escaped_length++;
2326 } else { 2326 } else {
2327 escaped_length += 3; 2327 escaped_length += 3;
2328 } 2328 }
2329 // We don't allow strings that are longer than Smi range. 2329 // We don't allow strings that are longer than Smi range.
2330 if (!Smi::IsValid(escaped_length)) { 2330 if (!Smi::IsValid(escaped_length)) {
2331 Top::context()->mark_out_of_memory(); 2331 Top::context()->mark_out_of_memory();
2332 return Failure::OutOfMemoryException(); 2332 return Failure::OutOfMemoryException();
2333 } 2333 }
2334 } 2334 }
2335 } 2335 }
2336 // No length change implies no change. Return original string if no change. 2336 // No length change implies no change. Return original string if no change.
2337 if (escaped_length == length) { 2337 if (escaped_length == length) {
2338 return source; 2338 return source;
2339 } 2339 }
2340 Object* o = Heap::AllocateRawAsciiString(escaped_length); 2340 Object* o = Heap::AllocateRawAsciiString(escaped_length);
2341 if (o->IsFailure()) return o; 2341 if (o->IsFailure()) return o;
2342 String* destination = String::cast(o); 2342 String* destination = String::cast(o);
2343 StringShape dshape(destination); 2343 StringShape dshape(destination);
2344 int dest_position = 0; 2344 int dest_position = 0;
2345 2345
2346 Access<StringInputBuffer> buffer(&string_input_buffer); 2346 Access<StringInputBuffer> buffer(&runtime_string_input_buffer);
2347 buffer->Rewind(); 2347 buffer->Rewind();
2348 while (buffer->has_more()) { 2348 while (buffer->has_more()) {
2349 uint16_t chr = buffer->GetNext(); 2349 uint16_t chr = buffer->GetNext();
2350 if (chr >= 256) { 2350 if (chr >= 256) {
2351 destination->Set(dshape, dest_position, '%'); 2351 destination->Set(dshape, dest_position, '%');
2352 destination->Set(dshape, dest_position+1, 'u'); 2352 destination->Set(dshape, dest_position+1, 'u');
2353 destination->Set(dshape, dest_position+2, hex_chars[chr >> 12]); 2353 destination->Set(dshape, dest_position+2, hex_chars[chr >> 12]);
2354 destination->Set(dshape, dest_position+3, hex_chars[(chr >> 8) & 0xf]); 2354 destination->Set(dshape, dest_position+3, hex_chars[(chr >> 8) & 0xf]);
2355 destination->Set(dshape, dest_position+4, hex_chars[(chr >> 4) & 0xf]); 2355 destination->Set(dshape, dest_position+4, hex_chars[(chr >> 4) & 0xf]);
2356 destination->Set(dshape, dest_position+5, hex_chars[chr & 0xf]); 2356 destination->Set(dshape, dest_position+5, hex_chars[chr & 0xf]);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
2572 Object* o = shape.IsAsciiRepresentation() 2572 Object* o = shape.IsAsciiRepresentation()
2573 ? Heap::AllocateRawAsciiString(length) 2573 ? Heap::AllocateRawAsciiString(length)
2574 : Heap::AllocateRawTwoByteString(length); 2574 : Heap::AllocateRawTwoByteString(length);
2575 if (o->IsFailure()) return o; 2575 if (o->IsFailure()) return o;
2576 String* result = String::cast(o); 2576 String* result = String::cast(o);
2577 StringShape result_shape(result); 2577 StringShape result_shape(result);
2578 bool has_changed_character = false; 2578 bool has_changed_character = false;
2579 2579
2580 // Convert all characters to upper case, assuming that they will fit 2580 // Convert all characters to upper case, assuming that they will fit
2581 // in the buffer 2581 // in the buffer
2582 Access<StringInputBuffer> buffer(&string_input_buffer); 2582 Access<StringInputBuffer> buffer(&runtime_string_input_buffer);
2583 buffer->Reset(s); 2583 buffer->Reset(s);
2584 unibrow::uchar chars[Converter::kMaxWidth]; 2584 unibrow::uchar chars[Converter::kMaxWidth];
2585 int i = 0; 2585 int i = 0;
2586 // We can assume that the string is not empty 2586 // We can assume that the string is not empty
2587 uc32 current = buffer->GetNext(); 2587 uc32 current = buffer->GetNext();
2588 while (i < length) { 2588 while (i < length) {
2589 bool has_next = buffer->has_more(); 2589 bool has_next = buffer->has_more();
2590 uc32 next = has_next ? buffer->GetNext() : 0; 2590 uc32 next = has_next ? buffer->GetNext() : 0;
2591 int char_length = mapping->get(current, next, chars); 2591 int char_length = mapping->get(current, next, chars);
2592 if (char_length == 0) { 2592 if (char_length == 0) {
(...skipping 3530 matching lines...) Expand 10 before | Expand all | Expand 10 after
6123 } else { 6123 } else {
6124 // Handle last resort GC and make sure to allow future allocations 6124 // Handle last resort GC and make sure to allow future allocations
6125 // to grow the heap without causing GCs (if possible). 6125 // to grow the heap without causing GCs (if possible).
6126 Counters::gc_last_resort_from_js.Increment(); 6126 Counters::gc_last_resort_from_js.Increment();
6127 Heap::CollectAllGarbage(); 6127 Heap::CollectAllGarbage();
6128 } 6128 }
6129 } 6129 }
6130 6130
6131 6131
6132 } } // namespace v8::internal 6132 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/interpreter-irregexp.cc ('k') | src/v8.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698