~ubuntu-branches/ubuntu/trusty/libv8-3.14/trusty

« back to all changes in this revision

Viewing changes to src/jsregexp.cc

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2014-02-12 10:26:54 UTC
  • Revision ID: package-import@ubuntu.com-20140212102654-mh2oalg31ifhjs0g
Tags: 3.14.5.8-5ubuntu1
* 0099_powerpc_support.patch: Pull in Andrew Low's powerpc port.
* debian/rules: Enable powerpc/ppc64/ppc64el for package builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
#include "x64/regexp-macro-assembler-x64.h"
51
51
#elif V8_TARGET_ARCH_ARM
52
52
#include "arm/regexp-macro-assembler-arm.h"
 
53
#elif V8_TARGET_ARCH_PPC
 
54
#include "ppc/regexp-macro-assembler-ppc.h"
53
55
#elif V8_TARGET_ARCH_MIPS
54
56
#include "mips/regexp-macro-assembler-mips.h"
55
57
#else
194
196
                         parse_result.error,
195
197
                         "malformed_regexp");
196
198
    return Handle<Object>::null();
197
 
  }
 
199
}
198
200
 
199
201
  bool has_been_compiled = false;
200
202
 
214
216
    if (!HasFewDifferentCharacters(atom_string)) {
215
217
      AtomCompile(re, pattern, flags, atom_string);
216
218
      has_been_compiled = true;
217
 
    }
218
219
  }
 
220
}
219
221
  if (!has_been_compiled) {
220
222
    IrregexpInitialize(re, pattern, flags, parse_result.capture_count);
221
223
  }
242
244
      ASSERT(!result.is_null() ||
243
245
             regexp->GetIsolate()->has_pending_exception());
244
246
      return result;
245
 
    }
 
247
  }
246
248
    default:
247
249
      UNREACHABLE();
248
250
      return Handle<Object>::null();
249
251
  }
250
 
}
 
252
  }
251
253
 
252
254
 
253
255
// RegExp Atom implementation: Simple string search using indexOf.
262
264
                                                 pattern,
263
265
                                                 flags,
264
266
                                                 match_pattern);
265
 
}
 
267
  }
266
268
 
267
269
 
268
270
static void SetAtomLastCapture(FixedArray* array,
356
358
  FixedArray* array = FixedArray::cast(last_match_info->elements());
357
359
  SetAtomLastCapture(array, *subject, output_registers[0], output_registers[1]);
358
360
  return last_match_info;
359
 
}
 
361
    }
360
362
 
361
363
 
362
364
// Irregexp implementation.
383
385
    re->SetDataAt(JSRegExp::code_index(is_ascii), saved_code);
384
386
    ASSERT(compiled_code->IsSmi());
385
387
    return true;
386
 
  }
 
388
    }
387
389
  return CompileIrregexp(re, sample_subject, is_ascii);
388
 
}
 
390
  }
389
391
 
390
392
 
391
393
static bool CreateRegExpErrorObjectAndThrow(Handle<JSRegExp> re,
397
399
  elements->set(0, re->Pattern());
398
400
  elements->set(1, *error_message);
399
401
  Handle<JSArray> array = factory->NewJSArrayWithElements(elements);
400
 
  Handle<Object> regexp_err =
 
402
    Handle<Object> regexp_err =
401
403
      factory->NewSyntaxError("malformed_regexp", array);
402
404
  isolate->Throw(*regexp_err);
403
405
  return false;
404
 
}
 
406
  }
405
407
 
406
408
 
407
409
bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re,
467
469
        isolate->factory()->NewStringFromUtf8(CStrVector(result.error_message));
468
470
    CreateRegExpErrorObjectAndThrow(re, is_ascii, error_message, isolate);
469
471
    return false;
470
 
  }
 
472
}
471
473
 
472
474
  Handle<FixedArray> data = Handle<FixedArray>(FixedArray::cast(re->data()));
473
475
  data->set(JSRegExp::code_index(is_ascii), result.code);
679
681
  }
680
682
  ASSERT(res == RE_FAILURE);
681
683
  return isolate->factory()->null_value();
682
 
}
 
684
  }
683
685
 
684
686
 
685
687
Handle<JSArray> RegExpImpl::SetLastMatchInfo(Handle<JSArray> last_match_info,
700
702
  SetLastSubject(array, *subject);
701
703
  SetLastInput(array, *subject);
702
704
  return last_match_info;
703
 
}
 
705
  }
704
706
 
705
707
 
706
708
RegExpImpl::GlobalCache::GlobalCache(Handle<JSRegExp> regexp,
1227
1229
  if (type() == ActionNode::CLEAR_CAPTURES) {
1228
1230
    Interval range = static_cast<DeferredClearCaptures*>(this)->range();
1229
1231
    return range.Contains(that);
1230
 
  } else {
 
1232
    } else {
1231
1233
    return reg() == that;
 
1234
    }
1232
1235
  }
1233
 
}
1234
1236
 
1235
1237
 
1236
1238
bool Trace::mentions_reg(int reg) {
1239
1241
       action = action->next()) {
1240
1242
    if (action->Mentions(reg))
1241
1243
      return true;
 
1244
    }
 
1245
  return false;
1242
1246
  }
1243
 
  return false;
1244
 
}
1245
1247
 
1246
1248
 
1247
1249
bool Trace::GetStoredPosition(int reg, int* cp_offset) {
1259
1261
    }
1260
1262
  }
1261
1263
  return false;
1262
 
}
 
1264
  }
1263
1265
 
1264
1266
 
1265
1267
int Trace::FindAffectedRegisters(OutSet* affected_registers,
1279
1281
    }
1280
1282
  }
1281
1283
  return max_register;
1282
 
}
 
1284
  }
1283
1285
 
1284
1286
 
1285
1287
void Trace::RestoreAffectedRegisters(RegExpMacroAssembler* assembler,
4973
4975
            alternation->AddAlternative(
4974
4976
                GuardedAlternative(body->ToNode(compiler, answer)));
4975
4977
            alternation->AddAlternative(GuardedAlternative(on_success));
4976
 
          } else {
 
4978
    } else {
4977
4979
            alternation->AddAlternative(GuardedAlternative(on_success));
4978
4980
            alternation->AddAlternative(
4979
4981
                GuardedAlternative(body->ToNode(compiler, answer)));
5517
5519
      break;
5518
5520
    }
5519
5521
    max = current.to();
5520
 
    i++;
5521
 
  }
 
5522
        i++;
 
5523
        }
5522
5524
  // Canonical until the i'th range. If that's all of them, we are done.
5523
5525
  if (i == n) return;
5524
5526
 
5538
5540
  character_ranges->Rewind(num_canonical);
5539
5541
 
5540
5542
  ASSERT(CharacterRange::IsCanonical(character_ranges));
5541
 
}
 
5543
      }
5542
5544
 
5543
5545
 
5544
5546
void CharacterRange::Negate(ZoneList<CharacterRange>* ranges,
5552
5554
  if (range_count > 0 && ranges->at(0).from() == 0) {
5553
5555
    from = ranges->at(0).to();
5554
5556
    i = 1;
5555
 
  }
 
5557
    }
5556
5558
  while (i < range_count) {
5557
5559
    CharacterRange range = ranges->at(i);
5558
5560
    negated_ranges->Add(CharacterRange(from + 1, range.from() - 1), zone);
5585
5587
  OutSet* result = new(zone) OutSet(first_, remaining_);
5586
5588
  result->Set(value, zone);
5587
5589
  successors(zone)->Add(result, zone);
5588
 
  return result;
 
5590
    return result;
5589
5591
}
5590
5592
 
5591
5593
 
5625
5627
    loc.set_value(Entry(current.from(), current.to(),
5626
5628
                        empty()->Extend(value, zone)));
5627
5629
    return;
5628
 
  }
 
5630
}
5629
5631
  // First see if there is a range to the left of this one that
5630
5632
  // overlaps.
5631
5633
  ZoneSplayTree<Config>::Locator loc;
6131
6133
#elif V8_TARGET_ARCH_ARM
6132
6134
  RegExpMacroAssemblerARM macro_assembler(mode, (data->capture_count + 1) * 2,
6133
6135
                                          zone);
 
6136
#elif V8_TARGET_ARCH_PPC
 
6137
  RegExpMacroAssemblerPPC macro_assembler(mode, (data->capture_count + 1) * 2,
 
6138
                                          zone);
6134
6139
#elif V8_TARGET_ARCH_MIPS
6135
6140
  RegExpMacroAssemblerMIPS macro_assembler(mode, (data->capture_count + 1) * 2,
6136
6141
                                           zone);